diff --git a/README.md b/README.md index 317c27f0c..d434dc1f3 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ List of Definitions * [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) +* [doT](https://github.com/olado/doT) (by [ZombieHunter](https://github.com/ZombieHunter)) * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) diff --git a/dot/dot-tests.ts b/dot/dot-tests.ts new file mode 100644 index 000000000..59e6cff75 --- /dev/null +++ b/dot/dot-tests.ts @@ -0,0 +1,32 @@ +/// + +var headertmpl = "

{{=it.title}}

"; + +var pagetmpl = "

Here is the page using a header template< / h2 >\n" + + "{{#def.header}}\n" + + "{{=it.name}}"; + +var customizableheadertmpl = "{{#def.header}}" + + "\n{{#def.mycustominjectionintoheader || ''} }"; + +var pagetmplwithcustomizableheader = "

Here is the page with customized header template

\n" + + "{{##def.mycustominjectionintoheader:\n" + + "
{{=it.title}} is not {{=it.name}}
\n" + + "#}}\n" + + "{{#def.customheader}}\n" + + "{{=it.name}}"; + +var def = { + header: headertmpl, + customheader: customizableheadertmpl +}; +var data = { + title: "My title", + name: "My name" +}; + +var pagefn = doT.template(pagetmpl, undefined, def); +var content = pagefn(data); + +pagefn = doT.template(pagetmplwithcustomizableheader, undefined, def); +var contentcustom = pagefn(data); diff --git a/dot/dot.d.ts b/dot/dot.d.ts new file mode 100644 index 000000000..2ab677c26 --- /dev/null +++ b/dot/dot.d.ts @@ -0,0 +1,50 @@ +// Type definitions for doT v1.0.1 +// Project: https://github.com/olado/doT +// Definitions by: ZombieHunter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var doT: doT.doTStatic; + +declare module doT { + + interface doTStatic { + /** + * Version number + */ + version: string; + /** + * Default template settings + */ + templateSettings: TemplateSettings; + + /** + * Compile template + */ + template(tmpl: string, c?: TemplateSettings, def?: Object): Function; + + /** + * For express + */ + compile(tmpl: string, def?: Object): Function; + } + + interface TemplateSettings { + evaluate: RegExp; + interpolate: RegExp; + encode: RegExp; + use: RegExp; + useParams: RegExp; + define: RegExp; + defineParams: RegExp; + conditional: RegExp; + iterate: RegExp; + varname: string; + strip: boolean; + append: boolean; + selfcontained: boolean; + } +} + +interface String { + encodeHTML(): string; +} \ No newline at end of file