1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | declare namespace Handlebars {
|
18 | export interface TemplateDelegate<T = any> {
|
19 | (context: T, options?: RuntimeOptions): string;
|
20 | }
|
21 |
|
22 | export type Template<T = any> = TemplateDelegate<T>|string;
|
23 |
|
24 | export interface RuntimeOptions {
|
25 | partial?: boolean;
|
26 | depths?: any[];
|
27 | helpers?: { [name: string]: Function };
|
28 | partials?: { [name: string]: HandlebarsTemplateDelegate };
|
29 | decorators?: { [name: string]: Function };
|
30 | data?: any;
|
31 | blockParams?: any[];
|
32 | allowCallsToHelperMissing?: boolean;
|
33 | allowedProtoProperties?: { [name: string]: boolean };
|
34 | allowedProtoMethods?: { [name: string]: boolean };
|
35 | allowProtoPropertiesByDefault?: boolean;
|
36 | allowProtoMethodsByDefault?: boolean;
|
37 | }
|
38 |
|
39 | export interface HelperOptions {
|
40 | fn: TemplateDelegate;
|
41 | inverse: TemplateDelegate;
|
42 | hash: any;
|
43 | data?: any;
|
44 | }
|
45 |
|
46 | export interface HelperDelegate {
|
47 | (context?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, options?: HelperOptions): any;
|
48 | }
|
49 | export interface HelperDeclareSpec {
|
50 | [key: string]: HelperDelegate;
|
51 | }
|
52 |
|
53 | export interface ParseOptions {
|
54 | srcName?: string;
|
55 | ignoreStandalone?: boolean;
|
56 | }
|
57 |
|
58 | export function registerHelper(name: string, fn: HelperDelegate): void;
|
59 | export function registerHelper(name: HelperDeclareSpec): void;
|
60 | export function unregisterHelper(name: string): void;
|
61 |
|
62 | export function registerPartial(name: string, fn: Template): void;
|
63 | export function registerPartial(spec: { [name: string]: HandlebarsTemplateDelegate }): void;
|
64 | export function unregisterPartial(name: string): void;
|
65 |
|
66 |
|
67 | export function registerDecorator(name: string, fn: Function): void;
|
68 | export function unregisterDecorator(name: string): void;
|
69 |
|
70 | export function K(): void;
|
71 | export function createFrame(object: any): any;
|
72 | export function blockParams(obj: any[], ids: any[]): any[];
|
73 | export function log(level: number, obj: any): void;
|
74 | export function parse(input: string, options?: ParseOptions): hbs.AST.Program;
|
75 | export function parseWithoutProcessing(input: string, options?: ParseOptions): hbs.AST.Program;
|
76 | export function compile<T = any>(input: any, options?: CompileOptions): HandlebarsTemplateDelegate<T>;
|
77 | export function precompile(input: any, options?: PrecompileOptions): TemplateSpecification;
|
78 | export function template<T = any>(precompilation: TemplateSpecification): HandlebarsTemplateDelegate<T>;
|
79 |
|
80 | export function create(): typeof Handlebars;
|
81 |
|
82 | export const escapeExpression: typeof Utils.escapeExpression;
|
83 |
|
84 | export const logger: Logger;
|
85 | export const templates: HandlebarsTemplates;
|
86 | export const helpers: { [name: string]: HelperDelegate };
|
87 | export const partials: { [name: string]: any };
|
88 |
|
89 | export const decorators: { [name: string]: Function };
|
90 |
|
91 | export const VERSION: string;
|
92 |
|
93 | export function noConflict(): typeof Handlebars;
|
94 |
|
95 | export class Exception {
|
96 | constructor(message: string, node?: hbs.AST.Node);
|
97 | description: string;
|
98 | fileName: string;
|
99 | lineNumber?: any;
|
100 | endLineNumber?: any;
|
101 | message: string;
|
102 | name: string;
|
103 | number: number;
|
104 | stack?: string;
|
105 | column?: any;
|
106 | endColumn?: any;
|
107 | }
|
108 |
|
109 | export class SafeString {
|
110 | constructor(str: string);
|
111 | toString(): string;
|
112 | toHTML(): string;
|
113 | }
|
114 |
|
115 | export namespace Utils {
|
116 | export function escapeExpression(str: string): string;
|
117 | export function createFrame(object: any): any;
|
118 | export function blockParams(obj: any[], ids: any[]): any[];
|
119 | export function isEmpty(obj: any) : boolean;
|
120 | export function extend(obj: any, ...source: any[]): any;
|
121 | export function toString(obj: any): string;
|
122 | export function isArray(obj: any): boolean;
|
123 | export function isFunction(obj: any): boolean;
|
124 | }
|
125 |
|
126 | export namespace AST {
|
127 | export const helpers: hbs.AST.helpers;
|
128 | }
|
129 |
|
130 | interface ICompiler {
|
131 | accept(node: hbs.AST.Node): void;
|
132 | Program(program: hbs.AST.Program): void;
|
133 | BlockStatement(block: hbs.AST.BlockStatement): void;
|
134 | PartialStatement(partial: hbs.AST.PartialStatement): void;
|
135 | PartialBlockStatement(partial: hbs.AST.PartialBlockStatement): void;
|
136 | DecoratorBlock(decorator: hbs.AST.DecoratorBlock): void;
|
137 | Decorator(decorator: hbs.AST.Decorator): void;
|
138 | MustacheStatement(mustache: hbs.AST.MustacheStatement): void;
|
139 | ContentStatement(content: hbs.AST.ContentStatement): void;
|
140 | CommentStatement(comment?: hbs.AST.CommentStatement): void;
|
141 | SubExpression(sexpr: hbs.AST.SubExpression): void;
|
142 | PathExpression(path: hbs.AST.PathExpression): void;
|
143 | StringLiteral(str: hbs.AST.StringLiteral): void;
|
144 | NumberLiteral(num: hbs.AST.NumberLiteral): void;
|
145 | BooleanLiteral(bool: hbs.AST.BooleanLiteral): void;
|
146 | UndefinedLiteral(): void;
|
147 | NullLiteral(): void;
|
148 | Hash(hash: hbs.AST.Hash): void;
|
149 | }
|
150 |
|
151 | export class Visitor implements ICompiler {
|
152 | accept(node: hbs.AST.Node): void;
|
153 | acceptKey(node: hbs.AST.Node, name: string): void;
|
154 | acceptArray(arr: hbs.AST.Expression[]): void;
|
155 | Program(program: hbs.AST.Program): void;
|
156 | BlockStatement(block: hbs.AST.BlockStatement): void;
|
157 | PartialStatement(partial: hbs.AST.PartialStatement): void;
|
158 | PartialBlockStatement(partial: hbs.AST.PartialBlockStatement): void;
|
159 | DecoratorBlock(decorator: hbs.AST.DecoratorBlock): void;
|
160 | Decorator(decorator: hbs.AST.Decorator): void;
|
161 | MustacheStatement(mustache: hbs.AST.MustacheStatement): void;
|
162 | ContentStatement(content: hbs.AST.ContentStatement): void;
|
163 | CommentStatement(comment?: hbs.AST.CommentStatement): void;
|
164 | SubExpression(sexpr: hbs.AST.SubExpression): void;
|
165 | PathExpression(path: hbs.AST.PathExpression): void;
|
166 | StringLiteral(str: hbs.AST.StringLiteral): void;
|
167 | NumberLiteral(num: hbs.AST.NumberLiteral): void;
|
168 | BooleanLiteral(bool: hbs.AST.BooleanLiteral): void;
|
169 | UndefinedLiteral(): void;
|
170 | NullLiteral(): void;
|
171 | Hash(hash: hbs.AST.Hash): void;
|
172 | }
|
173 |
|
174 |
|
175 | export interface ResolvePartialOptions {
|
176 | name: string;
|
177 | helpers?: { [name: string]: Function };
|
178 | partials?: { [name: string]: HandlebarsTemplateDelegate };
|
179 | decorators?: { [name: string]: Function };
|
180 | data?: any;
|
181 | }
|
182 |
|
183 | export namespace VM {
|
184 | |
185 |
|
186 |
|
187 | export function resolvePartial<T = any>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: ResolvePartialOptions): HandlebarsTemplateDelegate<T>;
|
188 | }
|
189 | }
|
190 |
|
191 |
|
192 |
|
193 |
|
194 | interface HandlebarsTemplatable {
|
195 | template: HandlebarsTemplateDelegate;
|
196 | }
|
197 |
|
198 |
|
199 | type HandlebarsTemplateDelegate<T = any> = Handlebars.TemplateDelegate<T>;
|
200 |
|
201 | interface HandlebarsTemplates {
|
202 | [index: string]: HandlebarsTemplateDelegate;
|
203 | }
|
204 |
|
205 | interface TemplateSpecification {
|
206 |
|
207 | }
|
208 |
|
209 |
|
210 | type RuntimeOptions = Handlebars.RuntimeOptions;
|
211 |
|
212 | interface CompileOptions {
|
213 | data?: boolean;
|
214 | compat?: boolean;
|
215 | knownHelpers?: KnownHelpers;
|
216 | knownHelpersOnly?: boolean;
|
217 | noEscape?: boolean;
|
218 | strict?: boolean;
|
219 | assumeObjects?: boolean;
|
220 | preventIndent?: boolean;
|
221 | ignoreStandalone?: boolean;
|
222 | explicitPartialContext?: boolean;
|
223 | }
|
224 |
|
225 | type KnownHelpers = {
|
226 | [name in BuiltinHelperName | CustomHelperName]: boolean;
|
227 | };
|
228 |
|
229 | type BuiltinHelperName =
|
230 | "helperMissing"|
|
231 | "blockHelperMissing"|
|
232 | "each"|
|
233 | "if"|
|
234 | "unless"|
|
235 | "with"|
|
236 | "log"|
|
237 | "lookup";
|
238 |
|
239 | type CustomHelperName = string;
|
240 |
|
241 | interface PrecompileOptions extends CompileOptions {
|
242 | srcName?: string;
|
243 | destName?: string;
|
244 | }
|
245 |
|
246 | declare namespace hbs {
|
247 |
|
248 | type SafeString = Handlebars.SafeString;
|
249 |
|
250 | type Utils = typeof Handlebars.Utils;
|
251 | }
|
252 |
|
253 | interface Logger {
|
254 | DEBUG: number;
|
255 | INFO: number;
|
256 | WARN: number;
|
257 | ERROR: number;
|
258 | level: number;
|
259 |
|
260 | methodMap: { [level: number]: string };
|
261 |
|
262 | log(level: number, obj: string): void;
|
263 | }
|
264 |
|
265 | type CompilerInfo = [number, string ];
|
266 |
|
267 | declare namespace hbs {
|
268 | namespace AST {
|
269 | interface Node {
|
270 | type: string;
|
271 | loc: SourceLocation;
|
272 | }
|
273 |
|
274 | interface SourceLocation {
|
275 | source: string;
|
276 | start: Position;
|
277 | end: Position;
|
278 | }
|
279 |
|
280 | interface Position {
|
281 | line: number;
|
282 | column: number;
|
283 | }
|
284 |
|
285 | interface Program extends Node {
|
286 | body: Statement[];
|
287 | blockParams: string[];
|
288 | }
|
289 |
|
290 | interface Statement extends Node {}
|
291 |
|
292 | interface MustacheStatement extends Statement {
|
293 | type: 'MustacheStatement';
|
294 | path: PathExpression | Literal;
|
295 | params: Expression[];
|
296 | hash: Hash;
|
297 | escaped: boolean;
|
298 | strip: StripFlags;
|
299 | }
|
300 |
|
301 | interface Decorator extends MustacheStatement { }
|
302 |
|
303 | interface BlockStatement extends Statement {
|
304 | type: 'BlockStatement';
|
305 | path: PathExpression;
|
306 | params: Expression[];
|
307 | hash: Hash;
|
308 | program: Program;
|
309 | inverse: Program;
|
310 | openStrip: StripFlags;
|
311 | inverseStrip: StripFlags;
|
312 | closeStrip: StripFlags;
|
313 | }
|
314 |
|
315 | interface DecoratorBlock extends BlockStatement { }
|
316 |
|
317 | interface PartialStatement extends Statement {
|
318 | type: 'PartialStatement';
|
319 | name: PathExpression | SubExpression;
|
320 | params: Expression[];
|
321 | hash: Hash;
|
322 | indent: string;
|
323 | strip: StripFlags;
|
324 | }
|
325 |
|
326 | interface PartialBlockStatement extends Statement {
|
327 | type: 'PartialBlockStatement';
|
328 | name: PathExpression | SubExpression;
|
329 | params: Expression[];
|
330 | hash: Hash;
|
331 | program: Program;
|
332 | openStrip: StripFlags;
|
333 | closeStrip: StripFlags;
|
334 | }
|
335 |
|
336 | interface ContentStatement extends Statement {
|
337 | type: 'ContentStatement';
|
338 | value: string;
|
339 | original: StripFlags;
|
340 | }
|
341 |
|
342 | interface CommentStatement extends Statement {
|
343 | type: 'CommentStatement';
|
344 | value: string;
|
345 | strip: StripFlags;
|
346 | }
|
347 |
|
348 | interface Expression extends Node {}
|
349 |
|
350 | interface SubExpression extends Expression {
|
351 | type: 'SubExpression';
|
352 | path: PathExpression;
|
353 | params: Expression[];
|
354 | hash: Hash;
|
355 | }
|
356 |
|
357 | interface PathExpression extends Expression {
|
358 | type: 'PathExpression';
|
359 | data: boolean;
|
360 | depth: number;
|
361 | parts: string[];
|
362 | original: string;
|
363 | }
|
364 |
|
365 | interface Literal extends Expression {}
|
366 | interface StringLiteral extends Literal {
|
367 | type: 'StringLiteral';
|
368 | value: string;
|
369 | original: string;
|
370 | }
|
371 |
|
372 | interface BooleanLiteral extends Literal {
|
373 | type: 'BooleanLiteral';
|
374 | value: boolean;
|
375 | original: boolean;
|
376 | }
|
377 |
|
378 | interface NumberLiteral extends Literal {
|
379 | type: 'NumberLiteral';
|
380 | value: number;
|
381 | original: number;
|
382 | }
|
383 |
|
384 | interface UndefinedLiteral extends Literal {
|
385 | type: 'UndefinedLiteral';
|
386 | }
|
387 |
|
388 | interface NullLiteral extends Literal {
|
389 | type: 'NullLiteral';
|
390 | }
|
391 |
|
392 | interface Hash extends Node {
|
393 | type: 'Hash';
|
394 | pairs: HashPair[];
|
395 | }
|
396 |
|
397 | interface HashPair extends Node {
|
398 | type: 'HashPair';
|
399 | key: string;
|
400 | value: Expression;
|
401 | }
|
402 |
|
403 | interface StripFlags {
|
404 | open: boolean;
|
405 | close: boolean;
|
406 | }
|
407 |
|
408 | interface helpers {
|
409 | helperExpression(node: Node): boolean;
|
410 | scopeId(path: PathExpression): boolean;
|
411 | simpleId(path: PathExpression): boolean;
|
412 | }
|
413 | }
|
414 | }
|
415 |
|
416 | declare module "handlebars" {
|
417 | export = Handlebars;
|
418 | }
|
419 |
|
420 | declare module "handlebars/runtime" {
|
421 | export = Handlebars;
|
422 | }
|