-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhoupeng
committed
Mar 1, 2018
1 parent
6240290
commit ae668ef
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
declare type artTemplateDefaults = { | ||
/** | ||
* template name | ||
*/ | ||
filename?: string; | ||
/** | ||
* an array of rules of template syntax | ||
*/ | ||
rules: any[]; | ||
/** | ||
* whether to automatically encode output statements of template. Setting false will close that functionality | ||
* escape can prevent XSS attacks | ||
*/ | ||
excape: boolean; | ||
/** | ||
* enable debug mode. If true: {cache:false, minimize:false, compileDebug:true} | ||
*/ | ||
debug: boolean; | ||
/** | ||
* if bail is set true, compilation errors and runtime errors will throw exception | ||
*/ | ||
bail: boolean; | ||
/** | ||
* whether to enable caching | ||
*/ | ||
cache: boolean; | ||
/** | ||
* whether to enable minimization. It will execute htmlMinifier and minimize HTML, CSS, JS | ||
* if template contains unclosing tags, please don't open minimize. Otherwise unclosing tags will be restored or filtered | ||
*/ | ||
minimize: boolean; | ||
|
||
/** | ||
* whether to compile in debug mode | ||
*/ | ||
compileDebug: boolean; | ||
/** | ||
* resolve template path | ||
*/ | ||
resolveFilename: any; | ||
/** | ||
* sub template compilation adapter | ||
*/ | ||
include: any, | ||
|
||
/** | ||
* HTML minifier. Work only in NodeJS environment | ||
*/ | ||
htmlMinifier: any; | ||
|
||
/** | ||
* HTML minifier configuration. Refer to: https://github.com/kangax/html-minifier | ||
*/ | ||
htmlMinifierOptions: { | ||
collapseWhitespace: boolean, | ||
minifyCSS: boolean, | ||
minifyJS: boolean, | ||
// automatically merged at runtime: rules.map(rule => rule.test) | ||
ignoreCustomFragments: any[] | ||
}; | ||
|
||
/** | ||
* error events. Work only if bail is false | ||
*/ | ||
onerror: any, | ||
|
||
/** | ||
* template file loader | ||
*/ | ||
loader: any, | ||
|
||
/** | ||
* cache center adapter (depend on filename field) | ||
*/ | ||
caches: any, | ||
|
||
/** | ||
* root directory of template. If filename field is not a local path, template will be found in root directory | ||
* @default '/' | ||
*/ | ||
root: string; | ||
|
||
/** | ||
* @default '.art' | ||
* default extension. If no extensions, extname will be automatically added | ||
*/ | ||
extname: string, | ||
|
||
/** | ||
* ignored variables. An array of template variables ignored by template compiler | ||
*/ | ||
ignore: any[], | ||
|
||
// imported template variables | ||
imports: { [key: string]: Function } | ||
} | ||
/** | ||
* | ||
* @param filenameOrTemplateId [ for bowser ] id of template [ for Node ] fileName of template | ||
* @param content [ if is Object ] return compile result , [ if is string ] return compile Funtion | ||
*/ | ||
declare function artTemplate(filenameOrTemplateId: string, content?: string | Object): any; | ||
declare namespace artTemplate { | ||
export const defaults: artTemplateDefaults; | ||
export const extension: { [key: string]: Function }; | ||
function render(source: string, data: any, options?: any): string; | ||
function compile(source: string, options?: any): (data: any) => string; | ||
} | ||
export = artTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters