UNPKG

1.34 kBTypeScriptView Raw
1interface Velocity {
2 parse(vmString: string, blocks?: { [blockName: string]: boolean }, ignoreSpace?: boolean): Array<VELOCITY_AST>
3 render(vmString: string, context?: RenderContext, macros?: Macros, config?: CompileConfig): string
4
5 Compile: Compile
6 Helper: Helper
7}
8
9interface Compile {
10 new (asts: Array<VELOCITY_AST>, config?: CompileConfig): Compile
11 render(context?: RenderContext, macros?: Macros, silence?: boolean): string
12
13 cost: number // render cost time
14}
15
16interface Helper {
17 getRefText(ast: VELOCITY_AST): string
18}
19
20type Macros = Object | { [macro: string]: Function }
21
22type RenderContext = Object | {
23 [contextKey: string]: Function,
24 eval(vmString: string, context?: RenderContext): string
25}
26
27type AST_TYPE = 'set' | 'elseif' | 'if' | 'else' | 'end' | 'foreach' | 'define' | 'content' | 'comment'
28 | 'macro' | 'macro_call' | 'math' | 'references' | 'method' | 'index' | 'property'
29 | 'bool' | 'interger' | 'decimal' | 'string' | 'array' | 'map'
30
31interface VELOCITY_AST {
32 type: AST_TYPE
33 value: any
34 id: string
35 pos: { first_line: number, first_column: number }
36}
37
38interface CompileConfig {
39 escape: boolean // escape variable
40 unescape: { [varName: string]: boolean } // unescape var config
41}
42
43declare module 'velocityjs' {
44 var velocityjs: Velocity;
45 export = velocityjs
46}