mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
Merge pull request #1694 from ZombieHunter/dot
Added definitions for doT (https://github.com/olado/doT)
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/// <reference path="dot.d.ts" />
|
||||
|
||||
var headertmpl = "<h1>{{=it.title}}</h1>";
|
||||
|
||||
var pagetmpl = "<h2>Here is the page using a header template< / h2 >\n"
|
||||
+ "{{#def.header}}\n"
|
||||
+ "{{=it.name}}";
|
||||
|
||||
var customizableheadertmpl = "{{#def.header}}"
|
||||
+ "\n{{#def.mycustominjectionintoheader || ''} }";
|
||||
|
||||
var pagetmplwithcustomizableheader = "<h2>Here is the page with customized header template</h2>\n"
|
||||
+ "{{##def.mycustominjectionintoheader:\n"
|
||||
+ " <div>{{=it.title}} is not {{=it.name}}</div>\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);
|
||||
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
// Type definitions for doT v1.0.1
|
||||
// Project: https://github.com/olado/doT
|
||||
// Definitions by: ZombieHunter <https://github.com/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;
|
||||
}
|
||||
Reference in New Issue
Block a user