-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
124 lines (104 loc) · 2.99 KB
/
index.d.ts
File metadata and controls
124 lines (104 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* Template compilation options
*/
export interface CompileOptions {
/** Block name to compile specific block */
block?: string;
/** Enable/disable caching */
cache?: boolean;
/** Cache directory name */
cacheName?: string;
}
/**
* Template data object - can be any object type
*/
export type TemplateData = Record<string, any>;
/**
* Compiled template function
*/
export interface CompiledTemplate {
(data?: TemplateData, subTemplate?: string): string;
}
/**
* Template rendering callback
*/
export interface RenderCallback {
(error: Error | null, result?: string): void;
}
/**
* Template compilation callback
*/
export interface CompileCallback {
(error: Error | null, templateFunction?: CompiledTemplate): void;
}
/**
* Main template engine interface
*/
export interface CBTemplate {
/** Template engine version */
version: string;
/** Left delimiter for template syntax */
leftDelimiter: string;
/** Right delimiter for template syntax */
rightDelimiter: string;
/** Default HTML escaping setting */
escape: boolean;
/** Base path for template files */
basePath: string;
/** Cache path for compiled templates */
cachePath: string;
/** Default file extension */
defaultExtName: string;
/**
* Compile template string to function
* @param str Template string
* @returns Compiled template function
*/
compile(str: string): CompiledTemplate;
/**
* Render template string with data
* @param str Template string
* @param data Template data
* @param subTemplate Sub template name
* @returns Rendered string
*/
render(str: string, data?: TemplateData, subTemplate?: string): string;
/**
* Compile template file with inheritance support
* @param filename Template file path
* @param options Compilation options
* @param callback Compilation callback
*/
compileFile(filename: string, options: CompileOptions, callback: CompileCallback): void;
compileFile(filename: string, callback: CompileCallback): void;
/**
* Render template file with data and inheritance support
* @param filename Template file path
* @param data Template data
* @param options Render options
* @param callback Render callback
*/
renderFile(filename: string, data: TemplateData, options: CompileOptions, callback: RenderCallback): void;
renderFile(filename: string, data: TemplateData, callback: RenderCallback): void;
/**
* Get new instance of template engine
* @returns New template engine instance
*/
getInstance(): CBTemplate;
/** Internal parse method */
_parse(str: string): string;
/** Internal build template function method */
_buildTemplateFunction(str: string): CompiledTemplate;
}
/**
* Template engine instance with static methods
*/
export interface CBTemplateStatic extends CBTemplate {
/**
* Get new instance of template engine
* @returns New template engine instance
*/
getInstance(): CBTemplate;
}
declare const cbTemplate: CBTemplateStatic;
export default cbTemplate;