Permalink
Browse files

doT.js in benchmarks

  • Loading branch information...
1 parent bf394d8 commit 413c7cb5d08dd6c25b7c6f45285635de1b675320 @olado committed Dec 28, 2011
Showing with 14 additions and 1 deletion.
  1. +14 −1 benchmarks/templating/doT.js
View
15 benchmarks/templating/doT.js
@@ -10,7 +10,7 @@
// Licensed under the MIT license.
//
(function() {
- var doT = { version : '0.1.6' };
+ var doT = { version : '0.1.7' };
if (typeof module !== 'undefined' && module.exports) {
module.exports = doT;
@@ -24,6 +24,8 @@
encode: /\{\{!([\s\S]+?)\}\}/g,
use: /\{\{#([\s\S]+?)\}\}/g, //compile time evaluation
define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g, //compile time defs
+ conditionalStart: /\{\{\?([\s\S]+?)\}\}/g,
+ conditionalEnd: /\{\{\?\}\}/g,
varname: 'it',
strip : true,
append: true
@@ -66,6 +68,13 @@
.replace(c.encode, function(match, code) {
return cstart + code.replace(/\\'/g, "'").replace(/\\\\/g, "\\").replace(/[\r\t\n]/g, ' ') + ").toString().replace(/&(?!\\w+;)/g, '&#38;').split('<').join('&#60;').split('>').join('&#62;').split('" + '"' + "').join('&#34;').split(" + '"' + "'" + '"' + ").join('&#39;').split('/').join('&#47;'" + cend;
})
+ .replace(c.conditionalEnd, function(match, expression) {
+ return "';}out+='";
+ })
+ .replace(c.conditionalStart, function(match, expression) {
+ var code = "if(" + expression + "){";
+ return "';" + code.replace(/\\'/g, "'").replace(/\\\\/g,"\\").replace(/[\r\t\n]/g, ' ') + "out+='";
+ })
.replace(c.evaluate, function(match, code) {
return "';" + code.replace(/\\'/g, "'").replace(/\\\\/g,"\\").replace(/[\r\t\n]/g, ' ') + "out+='";
})
@@ -83,4 +92,8 @@
throw e;
}
};
+
+ doT.compile = function(tmpl, def) {
+ return doT.template(tmpl, null, def);
+ };
}());

0 comments on commit 413c7cb

Please sign in to comment.