diff --git a/src/handlebars.test.ts b/src/handlebars.test.ts index 6f36cf1..c79c4ab 100644 --- a/src/handlebars.test.ts +++ b/src/handlebars.test.ts @@ -39,4 +39,15 @@ describe.concurrent("handlebars", () => { expect(result).toEqual(" services:"); }); + + it("allows statements in block", async (ctx) => { + const template = Handlebars.compile( + "{{#or POSTGRES_VERSION KAFKA_USAGE}}{{#if POSTGRES_VERSION}}POSTGRES{{/if}}{{#if KAFKA_USAGE}}KAFKA{{/if}}{{/or}}" + ); + const result = template({ + POSTGRES_VERSION: "14" + }); + + expect(result).toEqual("POSTGRES"); + }); }); diff --git a/src/handlebars.ts b/src/handlebars.ts index a580adb..dbeed8f 100644 --- a/src/handlebars.ts +++ b/src/handlebars.ts @@ -7,11 +7,11 @@ Handlebars.registerHelper("or", function (...params) { for (const value of params) { if (value) { - return options.fn(); + return options.fn(this); } } - return options.inverse(); + return options.inverse(this); }); export default Handlebars; diff --git a/tsconfig.json b/tsconfig.json index 76db3f6..3db7bc6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,10 @@ "compilerOptions": { "esModuleInterop": true, "module": "commonjs", - "noImplicitAny": true, + "noImplicitAny": false, "outDir": "./dist", "rootDir": "./src", - "strict": true, + "strict": false, "target": "es6" }, "exclude": ["node_modules", "**/*.test.ts"]