/
interface.ts
30 lines (28 loc) 路 1.04 KB
/
interface.ts
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
export interface RenderOptions {
name?: string;
root?: string;
locals?: Record<string, any>;
viewEngine?: string;
}
export interface IViewEngine {
/**
* Render a file by view engine, then set to body
* @param {String} name - the file path based on root
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
render(name: string, locals?: Record<string, any>, options?: RenderOptions): Promise<string>;
/**
* Render a template string by view engine
* @param {String} tpl - template string
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
renderString(
tpl: string,
locals?: Record<string, any>,
options?: RenderOptions
): Promise<string>;
}