Skip to content

Commit

Permalink
Merge pull request #31380 from zimmi88/handlebarsUpdateParseParams
Browse files Browse the repository at this point in the history
Update typings for handlebars: Add options param to parse
  • Loading branch information
sandersn committed Dec 19, 2018
2 parents 78f9020 + de10772 commit 75deea3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 8 additions & 1 deletion types/handlebars/handlebars-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//import Handlebars = require('handlebars');
import * as Handlerbars from 'handlebars';
import * as Handlebars from 'handlebars';

const context = {
author: { firstName: 'Alan', lastName: 'Johnson' },
Expand Down Expand Up @@ -78,3 +78,10 @@ template6([{url:"", title:""}])
const escapedExpression = Handlebars.Utils.escapeExpression('<script>alert(\'xss\');</script>');

Handlebars.helpers !== undefined;

const parsedTmpl = Handlebars.parse('<p>Hello, my name is {{name}}.</p>', {
srcName: "/foo/bar/baz.hbs",
ignoreStandalone: true
});

const parsedTmplWithoutOptions = Handlebars.parse('<p>Hello, my name is {{name}}.</p>');
7 changes: 6 additions & 1 deletion types/handlebars/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ declare namespace Handlebars {
[key: string]: HelperDelegate;
}

export interface ParseOptions {
srcName?: string,
ignoreStandalone?: boolean
}

export function registerHelper(name: string, fn: HelperDelegate): void;
export function registerHelper(name: HelperDeclareSpec): void;
export function unregisterHelper(name: string): void;
Expand All @@ -52,7 +57,7 @@ declare namespace Handlebars {
export function blockParams(obj: any[], ids: any[]): any[];
export function Exception(message: string): void;
export function log(level: number, obj: any): void;
export function parse(input: string): hbs.AST.Program;
export function parse(input: string, options?: ParseOptions): hbs.AST.Program;
export function compile<T = any>(input: any, options?: CompileOptions): HandlebarsTemplateDelegate<T>;
export function precompile(input: any, options?: PrecompileOptions): TemplateSpecification;
export function template<T = any>(precompilation: TemplateSpecification): HandlebarsTemplateDelegate<T>;
Expand Down
8 changes: 2 additions & 6 deletions types/handlebars/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"handlebars-tests.ts"
]
}
}
}

0 comments on commit 75deea3

Please sign in to comment.