fix typings of resolvePartial-options
- derived from the object structure seen in the debugger closes #1534
This commit is contained in:
+3
-3
@@ -5,15 +5,15 @@ module.exports = function(grunt) {
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
eslint: {
|
||||
options: {
|
||||
},
|
||||
files: [
|
||||
'*.js',
|
||||
'bench/**/*.js',
|
||||
'tasks/**/*.js',
|
||||
'lib/**/!(*.min|parser).js',
|
||||
'spec/**/!(*.amd|json2|require).js',
|
||||
'integration-testing/**/*.js'
|
||||
'integration-testing/multi-nodejs-test/*.js',
|
||||
'integration-testing/webpack-test/*.js',
|
||||
'integration-testing/webpack-test/src/*.js'
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
Vendored
+11
-2
@@ -8,6 +8,7 @@
|
||||
* - Sergei Dorogin <https://github.com/evil-shrike>
|
||||
* - webbiesdk <https://github.com/webbiesdk>
|
||||
* - Andrew Leedham <https://github.com/AndrewLeedham>
|
||||
* - Nils Knappmeier <https://github.com/nknapp>
|
||||
* For full history prior to their migration to handlebars.js, please see:
|
||||
* https://github.com/DefinitelyTyped/DefinitelyTyped/commits/1ce60bdc07f10e0b076778c6c953271c072bc894/types/handlebars/index.d.ts
|
||||
*/
|
||||
@@ -21,7 +22,6 @@ declare namespace Handlebars {
|
||||
export type Template<T = any> = TemplateDelegate<T>|string;
|
||||
|
||||
export interface RuntimeOptions {
|
||||
name?: string;
|
||||
partial?: boolean;
|
||||
depths?: any[];
|
||||
helpers?: { [name: string]: Function };
|
||||
@@ -150,11 +150,20 @@ declare namespace Handlebars {
|
||||
Hash(hash: hbs.AST.Hash): void;
|
||||
}
|
||||
|
||||
|
||||
export interface ResolvePartialOptions {
|
||||
name: string;
|
||||
helpers?: { [name: string]: Function };
|
||||
partials?: { [name: string]: HandlebarsTemplateDelegate };
|
||||
decorators?: { [name: string]: Function };
|
||||
data?: any;
|
||||
}
|
||||
|
||||
export namespace VM {
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export function resolvePartial<T = any>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: RuntimeOptions): HandlebarsTemplateDelegate<T>;
|
||||
export function resolvePartial<T = any>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: ResolvePartialOptions): HandlebarsTemplateDelegate<T>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -92,8 +92,8 @@ const parsedTmplWithoutOptions = Handlebars.parse('<p>Hello, my name is {{name}}
|
||||
|
||||
// Custom partial resolution.
|
||||
const originalResolvePartial = Handlebars.VM.resolvePartial;
|
||||
Handlebars.VM.resolvePartial = <T>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: RuntimeOptions): HandlebarsTemplateDelegate<T> => {
|
||||
const name = options.name;
|
||||
Handlebars.VM.resolvePartial = <T>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: Handlebars.ResolvePartialOptions): HandlebarsTemplateDelegate<T> => {
|
||||
const name = options.name.replace(/my/,'your');
|
||||
// transform name.
|
||||
options.name = name;
|
||||
return originalResolvePartial(partial, context, options);
|
||||
|
||||
Reference in New Issue
Block a user