From 6e210872b964181ba11a9ad023c94a90ff582cd4 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Tue, 20 Feb 2024 14:54:55 -0700 Subject: [PATCH 1/4] fix: update handlebars or statement variable usage --- src/handlebars.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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"); + }); }); From 95590495fc2c4afeb55a948668ccee319b9dc412 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Tue, 20 Feb 2024 15:04:38 -0700 Subject: [PATCH 2/4] pass in this --- src/handlebars.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 2676098d7ccdb0393aca44f0367a4d0ad15e9283 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Tue, 20 Feb 2024 15:07:05 -0700 Subject: [PATCH 3/4] dang typescript --- src/handlebars.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlebars.ts b/src/handlebars.ts index dbeed8f..ac8ea90 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(this); + return options.fn(this as any); } } - return options.inverse(this); + return options.inverse(this as any); }); export default Handlebars; From 870d49218d6486fac1861c0f7cacfed33129d979 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Tue, 20 Feb 2024 15:11:12 -0700 Subject: [PATCH 4/4] typescript can be ugh --- src/handlebars.ts | 4 ++-- tsconfig.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/handlebars.ts b/src/handlebars.ts index ac8ea90..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(this as any); + return options.fn(this); } } - return options.inverse(this as any); + 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"]