Skip to content

Commit

Permalink
Persist Handlebars in global to keep it through HMR. Fixes #744
Browse files Browse the repository at this point in the history
  • Loading branch information
mbleigh committed Aug 8, 2024
1 parent e7d9549 commit 85cc8f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/plugins/dotprompt/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { DocumentData } from '@genkit-ai/ai/retriever';
import Handlebars from 'handlebars';
import { PromptMetadata } from './metadata.js';

const Promptbars = Handlebars.create();
const Promptbars: typeof Handlebars =
global['dotprompt.handlebars'] || Handlebars.create();
global['dotprompt.handlebars'] = Promptbars;

function jsonHelper(serializable: any, options: { hash: { indent?: number } }) {
return new Promptbars.SafeString(
Expand Down

0 comments on commit 85cc8f3

Please sign in to comment.