Skip to content

Commit

Permalink
Persist Handlebars in global to keep it through HMR. Fixes #744 (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbleigh authored Aug 9, 2024
1 parent abd71c1 commit 08de4be
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 08de4be

Please sign in to comment.