Skip to content

Commit

Permalink
fix: Update handlebars to 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jan 10, 2020
1 parent 91cfe2e commit 2cbb089
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"@types/minimatch": "3.0.3",
"fs-extra": "^8.1.0",
"handlebars": "~4.5.3",
"handlebars": "^4.7.0",
"highlight.js": "^9.17.1",
"lodash": "^4.17.15",
"marked": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/output/plugins/MarkedPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
const contents = FS.readFileSync(path, 'utf-8');
if (path.substr(-4).toLocaleLowerCase() === '.hbs') {
const template = Handlebars.compile(contents);
return template(context);
return template(context, { allowProtoMethodsByDefault: true, allowProtoPropertiesByDefault: true });
} else {
return contents;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/output/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class Renderer extends ChildableComponent<Application, RendererComponent>

// Theme must be set as this is only called in render, and render ensures theme is set.
page.template = page.template || this.theme!.resources.templates.getResource(page.templateName)!.getTemplate();
page.contents = page.template(page);
page.contents = page.template(page, { allowProtoMethodsByDefault: true, allowProtoPropertiesByDefault: true });

this.trigger(PageEvent.END, page);
if (page.isDefaultPrevented) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/output/utils/resources/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export class Template<T = any> extends Resource {
return this.template;
}

render(context: any, options?: any): string {
render(context: any, options?: Handlebars.RuntimeOptions): string {
const template = this.getTemplate();
return template(context, options);
return template(context, { ...options, allowProtoMethodsByDefault: true, allowProtoPropertiesByDefault: true });
}
}

Expand Down

0 comments on commit 2cbb089

Please sign in to comment.