Comparing version 1.0.2 to 1.0.3
// doT.js | ||
// 2011, Laura Doktorova, https://github.com/olado/doT | ||
// 2011-2014, Laura Doktorova, https://github.com/olado/doT | ||
// Licensed under the MIT license. | ||
@@ -9,3 +9,3 @@ | ||
var doT = { | ||
version: '1.0.1', | ||
version: "1.0.3", | ||
templateSettings: { | ||
@@ -21,41 +21,43 @@ evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g, | ||
iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g, | ||
varname: 'it', | ||
varname: "it", | ||
strip: true, | ||
append: true, | ||
selfcontained: false | ||
selfcontained: false, | ||
doNotSkipEncoded: false | ||
}, | ||
template: undefined, //fn, compile template | ||
compile: undefined //fn, for express | ||
}, _globals; | ||
doT.encodeHTMLSource = function(doNotSkipEncoded) { | ||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/" }, | ||
matchHTML = doNotSkipEncoded ? /[&<>"'\/]/g : /&(?!#?\w+;)|<|>|"|'|\//g; | ||
return function(code) { | ||
return code ? code.toString().replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : ""; | ||
}; | ||
}; | ||
if (typeof module !== 'undefined' && module.exports) { | ||
_globals = (function(){ return this || (0,eval)("this"); }()); | ||
if (typeof module !== "undefined" && module.exports) { | ||
module.exports = doT; | ||
} else if (typeof define === 'function' && define.amd) { | ||
} else if (typeof define === "function" && define.amd) { | ||
define(function(){return doT;}); | ||
} else { | ||
(function(){ return this || (0,eval)('this'); }()).doT = doT; | ||
_globals.doT = doT; | ||
} | ||
function encodeHTMLSource() { | ||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }, | ||
matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g; | ||
return function() { | ||
return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this; | ||
}; | ||
} | ||
String.prototype.encodeHTML = encodeHTMLSource(); | ||
var startend = { | ||
append: { start: "'+(", end: ")+'", endencode: "||'').toString().encodeHTML()+'" }, | ||
split: { start: "';out+=(", end: ");out+='", endencode: "||'').toString().encodeHTML();out+='"} | ||
append: { start: "'+(", end: ")+'", startencode: "'+encodeHTML(" }, | ||
split: { start: "';out+=(", end: ");out+='", startencode: "';out+=encodeHTML(" } | ||
}, skip = /$^/; | ||
function resolveDefs(c, block, def) { | ||
return ((typeof block === 'string') ? block : block.toString()) | ||
return ((typeof block === "string") ? block : block.toString()) | ||
.replace(c.define || skip, function(m, code, assign, value) { | ||
if (code.indexOf('def.') === 0) { | ||
if (code.indexOf("def.") === 0) { | ||
code = code.substring(4); | ||
} | ||
if (!(code in def)) { | ||
if (assign === ':') { | ||
if (assign === ":") { | ||
if (c.defineParams) value.replace(c.defineParams, function(m, param, v) { | ||
@@ -69,3 +71,3 @@ def[code] = {arg: param, text: v}; | ||
} | ||
return ''; | ||
return ""; | ||
}) | ||
@@ -75,3 +77,3 @@ .replace(c.use || skip, function(m, code) { | ||
if (def[d] && def[d].arg && param) { | ||
var rw = (d+":"+param).replace(/'|\\/g, '_'); | ||
var rw = (d+":"+param).replace(/'|\\/g, "_"); | ||
def.__exp = def.__exp || {}; | ||
@@ -88,3 +90,3 @@ def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2"); | ||
function unescape(code) { | ||
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, ' '); | ||
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " "); | ||
} | ||
@@ -97,5 +99,5 @@ | ||
str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g,' ') | ||
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,''): str) | ||
.replace(/'|\\/g, '\\$&') | ||
str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ") | ||
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""): str) | ||
.replace(/'|\\/g, "\\$&") | ||
.replace(c.interpolate || skip, function(m, code) { | ||
@@ -106,3 +108,3 @@ return cse.start + unescape(code) + cse.end; | ||
needhtmlencode = true; | ||
return cse.start + unescape(code) + cse.endencode; | ||
return cse.startencode + unescape(code) + cse.end; | ||
}) | ||
@@ -124,8 +126,11 @@ .replace(c.conditional || skip, function(m, elsecase, code) { | ||
+ "';return out;") | ||
.replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r') | ||
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, '') | ||
.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); | ||
.replace(/\n/g, "\\n").replace(/\t/g, '\\t').replace(/\r/g, "\\r") | ||
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, ""); | ||
//.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); | ||
if (needhtmlencode && c.selfcontained) { | ||
str = "String.prototype.encodeHTML=(" + encodeHTMLSource.toString() + "());" + str; | ||
if (needhtmlencode) { | ||
if (!c.selfcontained && _globals && !_globals._encodeHTML) _globals._encodeHTML = doT.encodeHTMLSource(c.doNotSkipEncoded); | ||
str = "var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : (" | ||
+ doT.encodeHTMLSource.toString() + "(" + (c.doNotSkipEncoded || '') + "));" | ||
+ str; | ||
} | ||
@@ -135,3 +140,3 @@ try { | ||
} catch (e) { | ||
if (typeof console !== 'undefined') console.log("Could not create a template function: " + str); | ||
if (typeof console !== "undefined") console.log("Could not create a template function: " + str); | ||
throw e; | ||
@@ -138,0 +143,0 @@ } |
73
doT.js
// doT.js | ||
// 2011, Laura Doktorova, https://github.com/olado/doT | ||
// 2011-2014, Laura Doktorova, https://github.com/olado/doT | ||
// Licensed under the MIT license. | ||
@@ -9,3 +9,3 @@ | ||
var doT = { | ||
version: '1.0.1', | ||
version: "1.0.3", | ||
templateSettings: { | ||
@@ -21,41 +21,43 @@ evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g, | ||
iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g, | ||
varname: 'it', | ||
varname: "it", | ||
strip: true, | ||
append: true, | ||
selfcontained: false | ||
selfcontained: false, | ||
doNotSkipEncoded: false | ||
}, | ||
template: undefined, //fn, compile template | ||
compile: undefined //fn, for express | ||
}, _globals; | ||
doT.encodeHTMLSource = function(doNotSkipEncoded) { | ||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/" }, | ||
matchHTML = doNotSkipEncoded ? /[&<>"'\/]/g : /&(?!#?\w+;)|<|>|"|'|\//g; | ||
return function(code) { | ||
return code ? code.toString().replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : ""; | ||
}; | ||
}; | ||
if (typeof module !== 'undefined' && module.exports) { | ||
_globals = (function(){ return this || (0,eval)("this"); }()); | ||
if (typeof module !== "undefined" && module.exports) { | ||
module.exports = doT; | ||
} else if (typeof define === 'function' && define.amd) { | ||
} else if (typeof define === "function" && define.amd) { | ||
define(function(){return doT;}); | ||
} else { | ||
(function(){ return this || (0,eval)('this'); }()).doT = doT; | ||
_globals.doT = doT; | ||
} | ||
function encodeHTMLSource() { | ||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }, | ||
matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g; | ||
return function() { | ||
return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this; | ||
}; | ||
} | ||
String.prototype.encodeHTML = encodeHTMLSource(); | ||
var startend = { | ||
append: { start: "'+(", end: ")+'", endencode: "||'').toString().encodeHTML()+'" }, | ||
split: { start: "';out+=(", end: ");out+='", endencode: "||'').toString().encodeHTML();out+='"} | ||
append: { start: "'+(", end: ")+'", startencode: "'+encodeHTML(" }, | ||
split: { start: "';out+=(", end: ");out+='", startencode: "';out+=encodeHTML(" } | ||
}, skip = /$^/; | ||
function resolveDefs(c, block, def) { | ||
return ((typeof block === 'string') ? block : block.toString()) | ||
return ((typeof block === "string") ? block : block.toString()) | ||
.replace(c.define || skip, function(m, code, assign, value) { | ||
if (code.indexOf('def.') === 0) { | ||
if (code.indexOf("def.") === 0) { | ||
code = code.substring(4); | ||
} | ||
if (!(code in def)) { | ||
if (assign === ':') { | ||
if (assign === ":") { | ||
if (c.defineParams) value.replace(c.defineParams, function(m, param, v) { | ||
@@ -69,3 +71,3 @@ def[code] = {arg: param, text: v}; | ||
} | ||
return ''; | ||
return ""; | ||
}) | ||
@@ -75,3 +77,3 @@ .replace(c.use || skip, function(m, code) { | ||
if (def[d] && def[d].arg && param) { | ||
var rw = (d+":"+param).replace(/'|\\/g, '_'); | ||
var rw = (d+":"+param).replace(/'|\\/g, "_"); | ||
def.__exp = def.__exp || {}; | ||
@@ -88,3 +90,3 @@ def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2"); | ||
function unescape(code) { | ||
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, ' '); | ||
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " "); | ||
} | ||
@@ -97,5 +99,5 @@ | ||
str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g,' ') | ||
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,''): str) | ||
.replace(/'|\\/g, '\\$&') | ||
str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ") | ||
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""): str) | ||
.replace(/'|\\/g, "\\$&") | ||
.replace(c.interpolate || skip, function(m, code) { | ||
@@ -106,3 +108,3 @@ return cse.start + unescape(code) + cse.end; | ||
needhtmlencode = true; | ||
return cse.start + unescape(code) + cse.endencode; | ||
return cse.startencode + unescape(code) + cse.end; | ||
}) | ||
@@ -124,8 +126,11 @@ .replace(c.conditional || skip, function(m, elsecase, code) { | ||
+ "';return out;") | ||
.replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r') | ||
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, '') | ||
.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); | ||
.replace(/\n/g, "\\n").replace(/\t/g, '\\t').replace(/\r/g, "\\r") | ||
.replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, ""); | ||
//.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); | ||
if (needhtmlencode && c.selfcontained) { | ||
str = "String.prototype.encodeHTML=(" + encodeHTMLSource.toString() + "());" + str; | ||
if (needhtmlencode) { | ||
if (!c.selfcontained && _globals && !_globals._encodeHTML) _globals._encodeHTML = doT.encodeHTMLSource(c.doNotSkipEncoded); | ||
str = "var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : (" | ||
+ doT.encodeHTMLSource.toString() + "(" + (c.doNotSkipEncoded || '') + "));" | ||
+ str; | ||
} | ||
@@ -135,3 +140,3 @@ try { | ||
} catch (e) { | ||
if (typeof console !== 'undefined') console.log("Could not create a template function: " + str); | ||
if (typeof console !== "undefined") console.log("Could not create a template function: " + str); | ||
throw e; | ||
@@ -138,0 +143,0 @@ } |
@@ -1,7 +0,8 @@ | ||
/* Laura Doktorova https://github.com/olado/doT */(function(){function o(){var a={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},b=/&(?!#?\w+;)|<|>|"|'|\//g;return function(){return this?this.replace(b,function(c){return a[c]||c}):this}}function p(a,b,c){return(typeof b==="string"?b:b.toString()).replace(a.define||i,function(l,e,f,g){if(e.indexOf("def.")===0)e=e.substring(4);if(!(e in c))if(f===":"){a.defineParams&&g.replace(a.defineParams,function(n,h,d){c[e]={arg:h,text:d}});e in c||(c[e]=g)}else(new Function("def","def['"+ | ||
e+"']="+g))(c);return""}).replace(a.use||i,function(l,e){if(a.useParams)e=e.replace(a.useParams,function(g,n,h,d){if(c[h]&&c[h].arg&&d){g=(h+":"+d).replace(/'|\\/g,"_");c.__exp=c.__exp||{};c.__exp[g]=c[h].text.replace(RegExp("(^|[^\\w$])"+c[h].arg+"([^\\w$])","g"),"$1"+d+"$2");return n+"def.__exp['"+g+"']"}});var f=(new Function("def","return "+e))(c);return f?p(a,f,c):f})}function m(a){return a.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}var j={version:"1.0.1",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g, | ||
interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:true,append:true,selfcontained:false},template:undefined, | ||
compile:undefined};if(typeof module!=="undefined"&&module.exports)module.exports=j;else if(typeof define==="function"&&define.amd)define(function(){return j});else(function(){return this||(0,eval)("this")})().doT=j;String.prototype.encodeHTML=o();var q={append:{start:"'+(",end:")+'",endencode:"||'').toString().encodeHTML()+'"},split:{start:"';out+=(",end:");out+='",endencode:"||'').toString().encodeHTML();out+='"}},i=/$^/;j.template=function(a,b,c){b=b||j.templateSettings;var l=b.append?q.append: | ||
q.split,e,f=0,g;a=b.use||b.define?p(b,a,c||{}):a;a=("var out='"+(b.strip?a.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):a).replace(/'|\\/g,"\\$&").replace(b.interpolate||i,function(h,d){return l.start+m(d)+l.end}).replace(b.encode||i,function(h,d){e=true;return l.start+m(d)+l.endencode}).replace(b.conditional||i,function(h,d,k){return d?k?"';}else if("+m(k)+"){out+='":"';}else{out+='":k?"';if("+m(k)+"){out+='":"';}out+='"}).replace(b.iterate||i,function(h, | ||
d,k,r){if(!d)return"';} } out+='";f+=1;g=r||"i"+f;d=m(d);return"';var arr"+f+"="+d+";if(arr"+f+"){var "+k+","+g+"=-1,l"+f+"=arr"+f+".length-1;while("+g+"<l"+f+"){"+k+"=arr"+f+"["+g+"+=1];out+='"}).replace(b.evaluate||i,function(h,d){return"';"+m(d)+"out+='"})+"';return out;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)out\+='';/g,"$1").replace(/\+''/g,"").replace(/(\s|;|\}|^|\{)out\+=''\+/g,"$1out+=");if(e&&b.selfcontained)a="String.prototype.encodeHTML=("+ | ||
o.toString()+"());"+a;try{return new Function(b.varname,a)}catch(n){typeof console!=="undefined"&&console.log("Could not create a template function: "+a);throw n;}};j.compile=function(a,b){return j.template(a,null,b)}})(); | ||
/* Laura Doktorova https://github.com/olado/doT */ | ||
(function(){function p(b,a,d){return("string"===typeof a?a:a.toString()).replace(b.define||h,function(a,c,e,g){0===c.indexOf("def.")&&(c=c.substring(4));c in d||(":"===e?(b.defineParams&&g.replace(b.defineParams,function(a,b,l){d[c]={arg:b,text:l}}),c in d||(d[c]=g)):(new Function("def","def['"+c+"']="+g))(d));return""}).replace(b.use||h,function(a,c){b.useParams&&(c=c.replace(b.useParams,function(a,b,c,l){if(d[c]&&d[c].arg&&l)return a=(c+":"+l).replace(/'|\\/g,"_"),d.__exp=d.__exp||{},d.__exp[a]= | ||
d[c].text.replace(new RegExp("(^|[^\\w$])"+d[c].arg+"([^\\w$])","g"),"$1"+l+"$2"),b+"def.__exp['"+a+"']"}));var e=(new Function("def","return "+c))(d);return e?p(b,e,d):e})}function k(b){return b.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}var f={version:"1.0.3",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g, | ||
define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1},template:void 0,compile:void 0},m;f.encodeHTMLSource=function(b){var a={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=b?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;return function(b){return b? | ||
b.toString().replace(d,function(b){return a[b]||b}):""}};m=function(){return this||(0,eval)("this")}();"undefined"!==typeof module&&module.exports?module.exports=f:"function"===typeof define&&define.amd?define(function(){return f}):m.doT=f;var r={start:"'+(",end:")+'",startencode:"'+encodeHTML("},s={start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("},h=/$^/;f.template=function(b,a,d){a=a||f.templateSettings;var n=a.append?r:s,c,e=0,g;b=a.use||a.define?p(a,b,d||{}):b;b=("var out='"+(a.strip? | ||
b.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):b).replace(/'|\\/g,"\\$&").replace(a.interpolate||h,function(b,a){return n.start+k(a)+n.end}).replace(a.encode||h,function(b,a){c=!0;return n.startencode+k(a)+n.end}).replace(a.conditional||h,function(b,a,c){return a?c?"';}else if("+k(c)+"){out+='":"';}else{out+='":c?"';if("+k(c)+"){out+='":"';}out+='"}).replace(a.iterate||h,function(b,a,c,d){if(!a)return"';} } out+='";e+=1;g=d||"i"+e;a=k(a);return"';var arr"+ | ||
e+"="+a+";if(arr"+e+"){var "+c+","+g+"=-1,l"+e+"=arr"+e+".length-1;while("+g+"<l"+e+"){"+c+"=arr"+e+"["+g+"+=1];out+='"}).replace(a.evaluate||h,function(a,b){return"';"+k(b)+"out+='"})+"';return out;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)out\+='';/g,"$1").replace(/\+''/g,"");c&&(a.selfcontained||!m||m._encodeHTML||(m._encodeHTML=f.encodeHTMLSource(a.doNotSkipEncoded)),b="var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : ("+f.encodeHTMLSource.toString()+ | ||
"("+(a.doNotSkipEncoded||"")+"));"+b);try{return new Function(a.varname,b)}catch(q){throw"undefined"!==typeof console&&console.log("Could not create a template function: "+b),q;}};f.compile=function(b,a){return f.template(b,null,a)}})(); |
@@ -79,3 +79,3 @@ /* doT + auto-compilation of doT templates | ||
fs.writeFileSync(path, "(function(){" + compiled | ||
+ "var itself=" + modulename + ";" | ||
+ "var itself=" + modulename + ", _encodeHTML=(" + doT.encodeHTMLSource.toString() + "(" + (settings.doNotSkipEncoded || '') + "));" | ||
+ addexports(exports) | ||
@@ -82,0 +82,0 @@ + "if(typeof module!=='undefined' && module.exports) module.exports=itself;else if(typeof define==='function')define(function(){return itself;});else {" |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "index", | ||
@@ -13,0 +13,0 @@ "bin": { |
@@ -64,2 +64,7 @@ Created in search of the fastest and concise JavaScript templating function with emphasis on performance under V8 and nodejs. It shows great performance for both nodejs and browsers. | ||
## Example for express | ||
Many people are using doT with express. I added an example of the best way of doing it examples/express: | ||
[doT with express](examples/express) | ||
## Notes | ||
@@ -74,1 +79,9 @@ doU.js is here only so that legacy external tests do not break. Use doT.js. | ||
doT is licensed under the MIT License. (See LICENSE-DOT) | ||
<p align="center"> | ||
<img src="http://olado.github.io/doT/doT-js-100@2x.png" alt="logo by Kevin Kirchner"/> | ||
</p> | ||
Thank you Kevin Kirchner for the logo. | ||
@@ -11,3 +11,3 @@ var assert = require("assert"), doT = require("../doT"); | ||
it('should return a function', function(){ | ||
assert.equal("function", typeof basiccompiled); | ||
assert.equal(typeof basiccompiled, "function"); | ||
}); | ||
@@ -18,5 +18,5 @@ }); | ||
it('should render the template', function(){ | ||
assert.equal("<div>http</div>", basiccompiled({foo:"http"})); | ||
assert.equal("<div>http://abc.com</div>", basiccompiled({foo:"http://abc.com"})); | ||
assert.equal("<div></div>", basiccompiled({})); | ||
assert.equal(basiccompiled({foo:"http"}), "<div>http</div>"); | ||
assert.equal(basiccompiled({foo:"http://abc.com"}), "<div>http://abc.com</div>"); | ||
assert.equal(basiccompiled({}), "<div></div>"); | ||
}); | ||
@@ -27,7 +27,41 @@ }); | ||
it('should render define', function(){ | ||
assert.equal("<div>http</div>", definescompiled({foo:"http"})); | ||
assert.equal("<div>http://abc.com</div>", definescompiled({foo:"http://abc.com"})); | ||
assert.equal("<div></div>", definescompiled({})); | ||
assert.equal(definescompiled({foo:"http"}), "<div>http</div>"); | ||
assert.equal(definescompiled({foo:"http://abc.com"}), "<div>http://abc.com</div>"); | ||
assert.equal(definescompiled({}), "<div></div>"); | ||
}); | ||
}); | ||
describe('encoding with doNotSkipEncoded=false', function() { | ||
it('should not replace &', function() { | ||
global._encodeHTML = undefined; | ||
doT.templateSettings.doNotSkipEncoded = false; | ||
assert.equal(doT.template(definestemplate)({foo:"&"}), "<div>&</div>"); | ||
}); | ||
}); | ||
describe('evaluate 2 numbers', function() { | ||
it('should print numbers next to each other', function() { | ||
var fn = doT.template("{{=it.one}}{{=it.two}}"); | ||
assert.equal(fn({one:1, two: 2}), "12"); | ||
}); | ||
}); | ||
describe('evaluate 2 numbers in the middle', function() { | ||
it('should print numbers next to each other', function() { | ||
var fn = doT.template("{{?it.one}}{{=it.one}}{{?}}{{=it.one}}{{=it.two}}"); | ||
assert.equal(fn({one:1, two: 2}), "112"); | ||
}); | ||
}); | ||
describe('encoding with doNotSkipEncoded=true', function() { | ||
it('should replace &', function() { | ||
global._encodeHTML = undefined; | ||
doT.templateSettings.doNotSkipEncoded = true; | ||
assert.equal(doT.template(definestemplate)({foo:"&"}), "<div>&amp;</div>"); | ||
assert.equal(doT.template('{{!it.a}}')({a:"& < > / ' \""}), "& < > / ' ""); | ||
assert.equal(doT.template('{{!"& < > / \' \\""}}')(), "& < > / ' ""); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
62881
30
1384
86
5