Merge pull request #31380 from zimmi88/handlebarsUpdateParseParams

Update typings for handlebars: Add options param to parse
This commit is contained in:
Nathan Shively-Sanders
2018-12-19 09:48:06 -08:00
committed by GitHub
3 changed files with 16 additions and 8 deletions
+8 -1
View File
@@ -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' },
@@ -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>');
+6 -1
View File
@@ -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;
@@ -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>;
+2 -6
View File
@@ -19,9 +19,5 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"handlebars-tests.ts"
]
}
}
}