Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update handlebars or statement variable usage #34

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/handlebars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
4 changes: 2 additions & 2 deletions src/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading