Skip to content

Commit 960f2d8

Browse files
committed
support eq in handlebars
1 parent 89e8898 commit 960f2d8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎lib/src/overlays/transform.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@ export class SoyaTransform implements Overlays.OverlayPlugin {
8080
}
8181

8282
private hbCache = new Map<string, TemplateDelegate>();
83+
private hbHelpersRegistered = false;
84+
private ensureHbHelpers(): void {
85+
if (this.hbHelpersRegistered) return;
86+
if (!Handlebars.helpers || !(Handlebars.helpers as any).eq) {
87+
Handlebars.registerHelper("eq", (a: unknown, b: unknown) => a === b);
88+
}
89+
this.hbHelpersRegistered = true;
90+
}
8391

8492
private compileOnce(tpl: string): TemplateDelegate {
8593
let fn = this.hbCache.get(tpl);
8694
if (!fn) {
95+
this.ensureHbHelpers();
8796
fn = Handlebars.compile(tpl);
8897
this.hbCache.set(tpl, fn);
8998
}

0 commit comments

Comments
 (0)