Skip to content

Commit

Permalink
Merge pull request #523 from foolishchow/ts-declare
Browse files Browse the repository at this point in the history
add typescript declare
  • Loading branch information
aui authored Mar 1, 2018
2 parents 6240290 + ae668ef commit c74685e
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
109 changes: 109 additions & 0 deletions index.d.ts
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;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "art-template",
"typings":"index.d.ts",
"description": "JavaScript Template Engine",
"homepage": "http://aui.github.com/art-template/",
"version": "4.12.2",
Expand Down

0 comments on commit c74685e

Please sign in to comment.