JS Template Engines Performance (v158)

Revision 158 of this benchmark created by Samuil Gospodinov on


Description

Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type='text/javascript'>
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n","        ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
</script>

<script src="http://mustache.github.io/extras/mustache.js"></script>

<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/handlebars.1.0.0-rc.3.js"></script>

<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/kendo.core.min.2013.1.319.js"></script>

<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/dust-runtime-1.2.3.js"></script>

<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/tempo-2.0.js"></script>

<script src="https://rawgithub.com/danactive/js-template-engines-performance/master/lib/hogan-2.0.0.js"></script>

<script>
/**
*  Contemplate
*  Light-weight Template Engine for PHP, Python, Node and client-side JavaScript
*
*  @version: 0.6.6
*  https://github.com/foo123/Contemplate
*
*  @inspired by : Simple JavaScript Templating, John Resig - http://ejohn.org/ - MIT Licensed
*  http://ejohn.org/blog/javascript-micro-templating/
*
**/
!function(e,t,n){"object"==typeof module&&module.exports?module.exports=n():"function"==typeof define&&define.amd?define(n):e[t]=n()}(this.self||this,"Contemplate",function(e){"use strict";function t(e,t){var n,r={},u={},i={},o={},l={},a={};if(i[0]="HTML_SPECIALCHARS",i[1]="HTML_ENTITIES",o[0]="ENT_NOQUOTES",o[2]="ENT_COMPAT",o[3]="ENT_QUOTES",l=isNaN(e)?e?e.toUpperCase():"HTML_SPECIALCHARS":i[e],a=isNaN(t)?t?t.toUpperCase():"ENT_COMPAT":o[t],"HTML_SPECIALCHARS"!==l&&"HTML_ENTITIES"!==l)throw new Error("Table: "+l+" not supported");r[38]="&amp;","HTML_ENTITIES"===l&&(r[160]="&nbsp;",r[161]="&iexcl;",r[162]="&cent;",r[163]="&pound;",r[164]="&curren;",r[165]="&yen;",r[166]="&brvbar;",r[167]="&sect;",r[168]="&uml;",r[169]="&copy;",r[170]="&ordf;",r[171]="&laquo;",r[172]="&not;",r[173]="&shy;",r[174]="&reg;",r[175]="&macr;",r[176]="&deg;",r[177]="&plusmn;",r[178]="&sup2;",r[179]="&sup3;",r[180]="&acute;",r[181]="&micro;",r[182]="&para;",r[183]="&middot;",r[184]="&cedil;",r[185]="&sup1;",r[186]="&ordm;",r[187]="&raquo;",r[188]="&frac14;",r[189]="&frac12;",r[190]="&frac34;",r[191]="&iquest;",r[192]="&Agrave;",r[193]="&Aacute;",r[194]="&Acirc;",r[195]="&Atilde;",r[196]="&Auml;",r[197]="&Aring;",r[198]="&AElig;",r[199]="&Ccedil;",r[200]="&Egrave;",r[201]="&Eacute;",r[202]="&Ecirc;",r[203]="&Euml;",r[204]="&Igrave;",r[205]="&Iacute;",r[206]="&Icirc;",r[207]="&Iuml;",r[208]="&ETH;",r[209]="&Ntilde;",r[210]="&Ograve;",r[211]="&Oacute;",r[212]="&Ocirc;",r[213]="&Otilde;",r[214]="&Ouml;",r[215]="&times;",r[216]="&Oslash;",r[217]="&Ugrave;",r[218]="&Uacute;",r[219]="&Ucirc;",r[220]="&Uuml;",r[221]="&Yacute;",r[222]="&THORN;",r[223]="&szlig;",r[224]="&agrave;",r[225]="&aacute;",r[226]="&acirc;",r[227]="&atilde;",r[228]="&auml;",r[229]="&aring;",r[230]="&aelig;",r[231]="&ccedil;",r[232]="&egrave;",r[233]="&eacute;",r[234]="&ecirc;",r[235]="&euml;",r[236]="&igrave;",r[237]="&iacute;",r[238]="&icirc;",r[239]="&iuml;",r[240]="&eth;",r[241]="&ntilde;",r[242]="&ograve;",r[243]="&oacute;",r[244]="&ocirc;",r[245]="&otilde;",r[246]="&ouml;",r[247]="&divide;",r[248]="&oslash;",r[249]="&ugrave;",r[250]="&uacute;",r[251]="&ucirc;",r[252]="&uuml;",r[253]="&yacute;",r[254]="&thorn;",r[255]="&yuml;"),"ENT_NOQUOTES"!==a&&(r[34]="&quot;"),"ENT_QUOTES"===a&&(r[39]="&#39;"),r[60]="&lt;",r[62]="&gt;";for(n in r)r.hasOwnProperty(n)&&(u[String.fromCharCode(n)]=r[n]);return u}function n(e,n,r,u){var i=t("HTML_ENTITIES",n),o="";if(e=null==e?"":e+"",!i)return!1;if(n&&"ENT_QUOTES"===n&&(i["'"]="&#039;"),u||null==u)for(o in i)i.hasOwnProperty(o)&&(e=e.split(o).join(i[o]));else e=e.replace(/([\s\S]*?)(&(?:#\d+|#x[\da-f]+|[a-zA-Z][\da-z]*);|$)/g,function(e,t,n){for(o in i)i.hasOwnProperty(o)&&(t=t.split(o).join(i[o]));return t+n});return e}function r(e){return e=(e+"").toString(),encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")}function u(e,t){var n,r=0;if(null===e||"undefined"==typeof e)return 0;if(e.constructor!==Array&&e.constructor!==Object)return 1;"COUNT_RECURSIVE"===t&&(t=1),1!=t&&(t=0);for(n in e)e.hasOwnProperty(n)&&(r++,1!=t||!e[n]||e[n].constructor!==Array&&e[n].constructor!==Object||(r+=u(e[n],1)));return r}function i(e){var t,n=function(e){var t=/\W*function\s+([\w\$]+)\s*\(/.exec(e);return t?t[1]:"(Anonymous)"},r=function(e){if(!e||"object"!=typeof e||"number"!=typeof e.length)return!1;var t=e.length;return e[e.length]="bogus",t!==e.length?(e.length-=1,!0):(delete e[e.length],!1)};return e&&"object"==typeof e?(t=null,r(e)||(!t||0!==parseInt(t.local_value,10)&&(!t.local_value.toLowerCase||"off"!==t.local_value.toLowerCase()))&&"[object Object]"===Object.prototype.toString.call(e)&&"Object"===n(e.constructor)):!1}function o(e){var t,n={};if(e&&"object"==typeof e&&e.change_key_case)return e.flip();for(t in e)e.hasOwnProperty(t)&&(n[e[t]]=t);return n}function l(){var e=/%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g,t=arguments,n=0,r=t[n++],u=function(e,t,n,r){n||(n=" ");var u=e.length>=t?"":Array(1+t-e.length>>>0).join(n);return r?e+u:u+e},i=function(e,t,n,r,i,o){var l=r-e.length;return l>0&&(e=n||!i?u(e,r,o,n):e.slice(0,t.length)+u("",l,"0",!0)+e.slice(t.length)),e},o=function(e,t,n,r,o,l,a){var s=e>>>0;return n=n&&s&&{2:"0b",8:"0",16:"0x"}[t]||"",e=n+u(s.toString(t),l||0,"0",!1),i(e,n,r,o,a)},l=function(e,t,n,r,u,o){return null!=r&&(e=e.slice(0,r)),i(e,"",t,n,u,o)},a=function(e,r,a,s,c,f,d){var p,_,g,h,m;if("%%"==e)return"%";for(var v=!1,O="",E=!1,C=!1,b=" ",T=a.length,A=0;a&&T>A;A++)switch(a.charAt(A)){case" ":O=" ";break;case"+":O="+";break;case"-":v=!0;break;case"'":b=a.charAt(A+1);break;case"0":E=!0;break;case"#":C=!0}if(s=s?"*"==s?+t[n++]:"*"==s.charAt(0)?+t[s.slice(1,-1)]:+s:0,0>s&&(s=-s,v=!0),!isFinite(s))throw new Error("sprintf: (minimum-)width must be finite");switch(f=f?"*"==f?+t[n++]:"*"==f.charAt(0)?+t[f.slice(1,-1)]:+f:"fFeE".indexOf(d)>-1?6:"d"==d?0:void 0,m=r?t[r.slice(0,-1)]:t[n++],d){case"s":return l(String(m),v,s,f,E,b);case"c":return l(String.fromCharCode(+m),v,s,f,E);case"b":return o(m,2,C,v,s,f,E);case"o":return o(m,8,C,v,s,f,E);case"x":return o(m,16,C,v,s,f,E);case"X":return o(m,16,C,v,s,f,E).toUpperCase();case"u":return o(m,10,C,v,s,f,E);case"i":case"d":return p=+m||0,p=Math.round(p-p%1),_=0>p?"-":O,m=_+u(String(Math.abs(p)),f,"0",!1),i(m,_,v,s,E);case"e":case"E":case"f":case"F":case"g":case"G":return p=+m,_=0>p?"-":O,g=["toExponential","toFixed","toPrecision"]["efg".indexOf(d.toLowerCase())],h=["toString","toUpperCase"]["eEfFgG".indexOf(d)%2],m=_+Math.abs(p)[g](f),i(m,_,v,s,E)[h]();default:return e}};return r.replace(e,a)}function a(e,t){t=t?(t+"").replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g,"$1"):" \\s ";var n=new RegExp("^["+t+"]+","g");return(e+"").replace(n,"")}function s(e,t){t=t?(t+"").replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g,"\\$1"):" \\s ";var n=new RegExp("["+t+"]+$","g");return(e+"").replace(n,"")}function c(e,t){var n,r=0,u=0;for(e+="",t?(t+="",n=t.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g,"$1")):n=" \n\r   \f            ​\u2028\u2029 ",r=e.length,u=0;r>u;u++)if(-1===n.indexOf(e.charAt(u))){e=e.substring(u);break}for(r=e.length,u=r-1;u>=0;u--)if(-1===n.indexOf(e.charAt(u))){e=e.substring(0,u+1);break}return-1===n.indexOf(e.charAt(0))?e:""}function f(){return Math.floor((new Date).getTime()/1e3)}function d(e,t){var n,r,u,i=/\\?([a-z])/gi,o=function(e,t){return e=e.toString(),e.length<t?o("0"+e,t,"0"):e},l=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"];u=function(e,t){return r[e]?r[e]():t},r={d:function(){return o(r.j(),2)},D:function(){return r.l().slice(0,3)},j:function(){return n.getDate()},l:function(){return l[r.w()]+"day"},N:function(){return r.w()||7},S:function(){var e=r.j();return 4>e|e>20&&(["st","nd","rd"][e%10-1]||"th")},w:function(){return n.getDay()},z:function(){var e=new Date(r.Y(),r.n()-1,r.j()),t=new Date(r.Y(),0,1);return Math.round((e-t)/864e5)},W:function(){var e=new Date(r.Y(),r.n()-1,r.j()-r.N()+3),t=new Date(e.getFullYear(),0,4);return o(1+Math.round((e-t)/864e5/7),2)},F:function(){return l[6+r.n()]},m:function(){return o(r.n(),2)},M:function(){return r.F().slice(0,3)},n:function(){return n.getMonth()+1},t:function(){return new Date(r.Y(),r.n(),0).getDate()},L:function(){var e=r.Y();return e%4===0&e%100!==0|e%400===0},o:function(){var e=r.n(),t=r.W(),n=r.Y();return n+(12===e&&9>t?1:1===e&&t>9?-1:0)},Y:function(){return n.getFullYear()},y:function(){return r.Y().toString().slice(-2)},a:function(){return n.getHours()>11?"pm":"am"},A:function(){return r.a().toUpperCase()},B:function(){var e=3600*n.getUTCHours(),t=60*n.getUTCMinutes(),r=n.getUTCSeconds();return o(Math.floor((e+t+r+3600)/86.4)%1e3,3)},g:function(){return r.G()%12||12},G:function(){return n.getHours()},h:function(){return o(r.g(),2)},H:function(){return o(r.G(),2)},i:function(){return o(n.getMinutes(),2)},s:function(){return o(n.getSeconds(),2)},u:function(){return o(1e3*n.getMilliseconds(),6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)"},I:function(){var e=new Date(r.Y(),0),t=Date.UTC(r.Y(),0),n=new Date(r.Y(),6),u=Date.UTC(r.Y(),6);return e-t!==n-u?1:0},O:function(){var e=n.getTimezoneOffset(),t=Math.abs(e);return(e>0?"-":"+")+o(100*Math.floor(t/60)+t%60,4)},P:function(){var e=r.O();return e.substr(0,3)+":"+e.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-n.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(i,u)},r:function(){return"D, d M Y H:i:s O".replace(i,u)},U:function(){return n/1e3|0}};var a=function(e,t){return n=void 0===t?new Date:new Date(t instanceof Date?t:1e3*t),e.replace(i,u)};return a(e,t)}function p(e,t,n){for(var r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],u=d(t,n),i=0,o=r.length;o>i;i++)e[r[i]]&&(u=u.replace(r[i],e[r[i]]));return u}var _,g="0.6.6",h=Object,m=Array,v=String,O=Function,E=h.keys,C=parseInt,b=parseFloat,T=h.prototype,A=m.prototype,y=O.prototype,S=y.call.bind(T.toString),w=y.call.bind(T.hasOwnProperty),D=y.call.bind(A.slice),N="undefined"!=typeof global&&"[object global]"===S(global),j=function(e){return e instanceof m||"[object Array]"===S(e)},M=N?require("fs"):null,I=M?M.writeFileSync:null,x=M?M.readFileSync:null,L=M?M.existsSync:null,k=M?M.statSync:null,U=(M?M.realpathSync:null,M?M.writeFile:null),K=M?M.readFile:null,H=(M?M.exists:null,M?M.stat:null,M?M.realpath:null,function(e,t,n,r){var u;return u=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),r?(u.onload=function(){r(200===u.status?u.responseText:"")},u.open(e,t,!0),u.send(n),""):(u.open(e,t,!1),u.send(n),200===u.status?u.responseText:"")}),R=!1,F={},P={},B=!1,$=0,G="./",Y={},q={},z={},V={},J="<%",W="%>",X="",Z="",Q="",et="' + \"\\n\" + '",tt="",nt=N?require("os").EOL:"\n",rt=!0,ut=null,it=0,ot="    ",lt=0,at=0,st=0,ct=0,ft=2,dt=null,pt=null,_t=null,gt=null,ht=null,mt=-1,vt=null,Ot=0,Et=/[ -]/g,Ct=/\n\r|\r\n|\n|\r/g,bt=/^[a-zA-Z_]/,Tt=/^[0-9]/,At=/^[a-zA-Z0-9_]/i,yt=/^\s/,St={specials:null,replacements:null,functions:null,controls:null,controls2:null},wt=["include","template","extends","endblock","block","elsefor","endfor","for","set","unset","isset","elseif","else","endif","if"],Dt=["htmlselect","htmltable","plugin_([a-zA-Z0-9_]+)","haskey","lowercase","uppercase","camelcase","snakecase","pluralise","concat","ltrim","rtrim","trim","sprintf","addslashes","stripslashes","tpl","uuid","html","url","count","ldate","date","now","locale","dq","q","l","s","n","f"],Nt={},jt=function(){at=0,st=0,ct=0,ft=2,it=0,dt=[],pt={},_t=[[null,-1]],vt=null},Mt=function(){ut.push([at,st,ct,ft,it,dt,pt,_t,vt])},It=function(){var e=ut.pop();at=e[0],st=e[1],ct=e[2],ft=e[3],it=e[4],dt=e[5],pt=e[6],_t=e[7],vt=e[8]},xt=function(){return D(arguments).join(nt)},Lt=function(e,t){if(2>arguments.length&&(t=it),t>=0){t=0===t?t:t+1;var n,r,u=new m(t).join(ot);for(e=e.split(Ct),r=e.length,n=0;r>n;n++)e[n]=u+e[n];return e.join(nt)}return e},kt=function(){var e=D(arguments);if(!(e.length<1)){var t,n,r,u=e.shift(),i=e.length;for(t=0;i>t;t++)if(r=e[t])for(n in r)w(r,n)&&(u[n]=r[n]);return u}},Ut=function(e,t){var n,r;if(t)r=c(t).split(" "),J=c(r[0]),W=c(r[1]);else{for(n=e.split("\n");n.length&&!c(n[0]).length;)n.shift();n.length&&(r=c(n.shift()).split(" "),J=c(r[0]),W=c(r[1])),e=n.join("\n")}return e},Kt=function(e,t){return V[e]?B&&t?(t(V[e]),""):V[e]:q[e]?N&&M?B&&t?(K(q[e],{encoding:_.ENCODING},function(e,n){t(e?"":n)}),""):x(q[e],{encoding:_.ENCODING}):"#"===q[e].charAt(0)?B&&t?(t(window.document.getElementById(q[e].substring(1)).innerHTML||""),""):window.document.getElementById(q[e].substring(1)).innerHTML||"":B&&t?(H("GET",q[e],null,t),""):H("GET",q[e]):""},Ht=function(e){return' ("undefined" !== typeof('+e+")) "},Rt=function(e){e=e.split(",");var t=c(e.shift()),n=c(e.join(","));return"';"+nt+Lt(t+" = ("+n+");")+nt},Ft=function(e){return e&&e.length?(e=c(e),"';"+nt+Lt('if ("undefined" !== typeof('+e+")) delete "+e+";")+nt):"'; "+nt},Pt=function(e){var t="';"+Lt(hn({IFCOND:e}));return st++,it++,t},Bt=function(e){it--;var t="';"+Lt(mn({ELIFCOND:e}));return it++,t},$t=function(){it--;var e="';"+Lt(vn());return it++,e},Gt=function(){st--,it--;var e="';"+Lt(On());return e},Yt=function(e){e=e.split(" as ");var t,n=c(e[0]),r="_O"+ ++lt,u=e[1].split("=>"),i=u.length>=2;if(i){var o=c(u[0])+"__RAW__",l=c(u[1])+"__RAW__",a="_OK"+ ++lt,s="_K"+ ++lt,f="_L"+ ++lt,d="_V"+ ++lt;t="';"+Lt(En({O:n,_O:r,_OK:a,K:o,_K:s,_L:f,V:l,_V:d,ASSIGN1:"data['"+o+"'] = "+a+"["+s+"]; data['"+l+"'] = "+d+" = "+r+"["+a+"["+s+"]];"},2)),ft=2,it+=2}else{var l=c(u[0])+"__RAW__",s="_K"+ ++lt,f="_L"+ ++lt,d="_V"+ ++lt;t="';"+Lt(En({O:n,_O:r,_K:s,_L:f,V:l,_V:d,ASSIGN1:"data['"+l+"'] = "+d+" = "+r+"["+s+"];"},1)),ft=1,it+=2}return at++,ct++,t},qt=function(){var e;return 2===ft?(ct--,it+=-2,e="';"+Lt(Cn(null,2)),it+=1):(ct--,it+=-2,e="';"+Lt(Cn(null,1)),it+=1),e},zt=function(){var e;return ct===at?2===ft?(at--,ct--,it+=-2,e="';"+Lt(bn(null,3))):(at--,ct--,it+=-2,e="';"+Lt(bn(null,2))):(at--,it+=-1,e="';"+Lt(bn(null,1))),e},Vt=function(e){return z[e]||(Mt(),jt(),z[e]=" "+on(Ut(Kt(e)),!1)+"'; "+nt,It()),Lt(z[e])},Jt=function(e){e=e.split(",");var t=c(e.shift()),n=e.join(",");return"' + %tpl( \""+t+'", '+n+" ); "+nt},Wt=function(e){return vt=c(e),"'; "+nt},Xt=function(e){return e=c(e),dt.push([e,-1,-1,0,_t[0][1]]),pt[e]=pt[e]?pt[e]+1:1,mt=dt.length,_t.unshift([e,mt-1]),gt=e,ht=null,"' +  __||"+e+"||__"},Zt=function(){if(1<_t.length){var e=_t.shift();return ht=e[0],mt=e[1]+1,gt=null,"__||/"+e[0]+"||__"}return""},Qt=function(e,t,n){var r,u,i,o,l;for(r=e.split(t),u=r.length,i=[],o=0;u>o;o++)l=r[o].split(n),i.push(l[0]),l.length>1&&i.push(l[1]);return i},en=function(e,t,n){if(t)switch(n=n||"",t){case"isset":return n=n.replace(St.controls2,en),Ht(n);case"set":return n=n.replace(St.controls2,en),Rt(n);case"unset":return n=n.replace(St.controls2,en),Ft(n);case"if":return n=n.replace(St.controls2,en),Pt(n);case"elseif":return n=n.replace(St.controls2,en),Bt(n);case"else":return $t(n);case"endif":return Gt(n);case"for":return n=n.replace(St.controls2,en),Yt(n);case"elsefor":return qt(n);case"endfor":return zt(n);case"extends":return Wt(n);case"block":return Xt(n);case"endblock":return Zt(n);case"template":return n=n.replace(St.controls2,en),Jt(n);case"include":return Vt(n)}return e},tn=function(e){for(var t,n,r,u,i,o,l,a,s,c,f={},d=dt.length;d--;)n=dt[d],t=n[0],l=n[1],a=n[2],s=n[3],c=n[4],r="__||"+t+"||__",u="__i__.renderBlock( '"+t+"' ); ",i=r.length,o=u.length,c>-1&&(dt[c][3]+=o-(a-l+1)),a+=s,1===pt[t]&&(f[t]=gn({BLOCKCODE:e.slice(l+i,a-i-1)+"';"})),e=e.slice(0,l)+u+e.slice(a+1),1<=pt[t]&&pt[t]--;return dt=null,pt=null,_t=null,[e,f]},nn=function(e,t,n,r){for(var u=t,i=!1,o="";r>n&&(o=e[n++],u+=o,t!==o||i);)i=!i&&"\\"===o;return u},rn=function(e,t,n,r){if(r=r||"VARSTR",bt.test(e[t])){var u,i,o,l,a,s,c,f,d,p,_,g=0,h={},m=[],v=0;for(i=e[t++];n>t&&At.test(e[t]);)i+=e[t++];for(l=i,i="data['"+i+"']",a=l.length,v=0;n>t&&yt.test(e[t]);)v++,t++;for(c=0;n>t&&("."===e[t]||"["===e[t]);){for(f=e[t++];n>t&&yt.test(e[t]);)v++,t++;if("."===f){for(o="";n>t&&At.test(e[t]);)o+=e[t++];if(s=o.length,!s)break;i+="['"+o+"']",a+=v+1+s,v=0}else if("["===f){if(c++,d=e[t],'"'===d||"'"===d)o=nn(e,d,t+1,n),g++,p="__##"+r+g+"##__",h[p]=o,i+=f+p,s=o.length,t+=s,a+=v+1+s,v=0;else if(Tt.test(d)){for(o=e[t++];n>t&&Tt.test(e[t]);)o+=e[t++];i+=f+o,s=o.length,a+=v+1+s,v=0}else if("$"===d)_=e.slice(t+1),u=rn(_,0,_.length,r+"_"+g+"_"),u&&(o=u[u.length-1],i+=f+o[0][0],s=o[1],t+=s+1,a+=v+2+s,v=0,m=m.concat(u));else{if("]"!==d)break;if(!(c>0))break;c--,i+=f+e[t++],a+=v+2,v=0}for(;n>t&&yt.test(e[t]);)v++,t++;if("]"===e[t]){if(!(c>0))break;c--,i+=e[t++],a+=v+1,v=0}}for(;n>t&&yt.test(e[t]);)v++,t++}return m.push([[i,l],a,h]),m}return null},un=function(e,t,n){return n&&Nt[n]?"Contemplate.plugin_"+n:"Contemplate."+t},on=function(e,t){var n,r,u,i,o,l,a,s,c,f,d,p,g,h,m,v,O,E;for(n=Qt(e,J,W),r=n.length,l=!1,u="",o=0;r>o;o++){if(i=n[o],l){for(a=" "+i.replace(St.specials," ")+"",d=a.length,c={},s={},p=0,g="",h="",m=0;d>p;)if(g=a[p++],'"'===g||"'"===g)v=nn(a,g,p,d),m++,f="__##STR"+m+"##__",s[f]=v,h+=f,p+=v.length-1;else if("$"===g)if(v=rn(a,p,d)){for(O=0;O<v.length;O++)E=v[O],m++,f="__##VAR"+m+"##__",c[f]=E[0],s=_.merge(s,E[2]);h+=f,p+=E[1]}else h+="$";else h+=g;a=h,gt=null,ht=null,mt=-1,a=a.replace(St.controls,en).replace(St.functions,un).replace(St.replacements,"' + ( $1 ) + '");for(f in c)a=a.split(f+"__RAW__").join(c[f][1]),a=a.split(f).join(c[f][0]);for(f in s)a=a.split(f).join(s[f]);i=a.split("     ").join(X).split("").join(Lt(Z)),gt?(gt="__||"+gt+"||__",dt[mt-1][1]=u.length+a.indexOf(gt)):ht&&(ht="__||/"+ht+"||__",dt[mt-1][2]=u.length+a.indexOf(ht)+ht.length),l=!1}else rt&&(i=i.split("\\").join("\\\\")),i=i.split("'").join("\\'").split(/\n/).join(tt),l=!0;u+=i}return!1!==t?tn(u):u},ln=function(e){return G+e.replace(Et,"_")+"_tpl.js"},an=function(e){return"Contemplate_"+e.replace(Et,"_")+"_Cached"},sn=function(e,t){jt();var n,r,u=on(Ut(Kt(e),t)),i={};r=vt?Tn(null,1):Tn({FCODE:"__p__ += '"+u[0]+"';"},2);for(n in u[1])i[n]=new O("Contemplate,__i__",u[1][n]);return[new O("Contemplate,__i__",r),i]},cn=function(e,t,n,r){jt();var u,i,o,l,a,s,c=on(Ut(Kt(e),r));a=[];for(l in c[1])s=nt+_n({BLOCKNAME:l,BLOCKMETHODNAME:l,BLOCKMETHODCODE:Lt(c[1][l],1)}),a.push(s);a=a.length?nt+"_blocks = { "+nt+Lt(a.join(","+nt),1)+nt+"};"+nt:"",vt?(i="this.extend( '"+vt+"' );",o=An(null,1)):(i="",o=An({RCODE:"__p__ += '"+c[0]+"';"},2)),u=Q?Q:"";var f=pn({CLASSNAME:n,TPLID:e,PREFIXCODE:u,EXTENDCODE:Lt(i,2),BLOCKS:Lt(a,2),RENDERCODE:Lt(o,4)});return dn(t,f)},fn=function(e,t){if(t=t||{},V[e]){var n=sn(e,t.separators),r=yn(_,e,n[0]).setBlocks(n[1]);return vt&&r.extend(_.tpl(vt)),r}if(N||($=_.CACHE_TO_DISK_NONE),!0!==t.autoUpdate&&_.CACHE_TO_DISK_NOUPDATE===$){var u=ln(e),i=an(e);if(L(u)||cn(e,u,i,t.separators),L(u)){var o=require(u)(_),r=(new o).setId(e);return r}return null}if(!0===t.autoUpdate||_.CACHE_TO_DISK_AUTOUPDATE===$){var u=ln(e),i=an(e);if(L(u)){var l=k(u),a=k(q[e]);l.mtime.getTime()<=a.mtime.getTime()&&cn(e,u,i,t.separators)}else cn(e,u,i,t.separators);if(L(u)){var o=require(u)(_),r=(new o).setId(e);return r}return null}var n=sn(e,t.separators),r=yn(_,e,n[0]).setBlocks(n[1]);return vt&&r.extend(_.tpl(vt)),r},dn=function(e,t,n){return n?void U(e,t,{encoding:_.ENCODING},function(e){n(!e)}):I(e,t,{encoding:_.ENCODING})},pn=function(e){var t=xt;return[e.PREFIXCODE,t("","!function (root, moduleName, moduleDefinition) {","","    //","    // export the module","","    // node, CommonJS, etc..","    if ( 'object' === typeof(module) && module.exports ) module.exports = moduleDefinition();","","    // AMD, etc..","    else if ( 'function' === typeof(define) && define.amd ) define( moduleDefinition );","","    // browser, etc..","    else root[ moduleName ] = moduleDefinition();","","","}(this, '"),e.CLASSNAME,t("', function( ) {",'    "use strict";',"    return function( Contemplate ) {","    /* Contemplate cached template '"),e.TPLID,t("' */","    /* quasi extends main Contemplate class */","    ","    var Contemplate_tpl = Contemplate.tpl;","    ","    /* constructor */","    function "),e.CLASSNAME,t("(id)","    {","        /* initialize internal vars */","        var _extends = null, _blocks = null;","        ","        this.id = id;","        this.d = null;","        ","        ","        /* tpl-defined blocks render code starts here */",""),e.BLOCKS,t("","        /* tpl-defined blocks render code ends here */","        ","        /* template methods */","        ","        this.setId = function(id) {","            if ( id ) this.id = id;","            return this;","        };","        ","        this.extend = function(tpl) {","            if ( tpl && tpl.substr )","                _extends = Contemplate_tpl( tpl );","            else","                _extends = tpl;","            return this;","        };","        ","        /* render a tpl block method */","        this.renderBlock = function(block, __i__) {","            if ( !__i__ ) __i__ = this;","            if ( _blocks && _blocks[block] ) return _blocks[block](__i__);","            else if ( _extends ) return _extends.renderBlock(block, __i__);","            return '';","        };","        ","        /* tpl render method */","        this.render = function(data, __i__) {","            if ( !__i__ ) __i__ = this;","            var __p__ = '';","            if ( _extends )","            {","                __p__ = _extends.render(data, __i__);","            }","            else","            {","                /* tpl main render code starts here */",""),e.RENDERCODE,t("","                /* tpl main render code ends here */","            }","            this.d = null;","            return __p__;","        };","        ","        /* extend tpl assign code starts here */",""),e.EXTENDCODE,t("","        /* extend tpl assign code ends here */","    };","    ","    ","    // export it","    return "),e.CLASSNAME,t(";","    };","});","")].join("")},_n=function(e){var t=xt;return[t("","/* tpl block render method for block '"),e.BLOCKNAME,t("' */","'"),e.BLOCKMETHODNAME,t("': function(__i__) {",""),e.BLOCKMETHODCODE,t("","}","")].join("")},gn=function(e){var t=xt;return[t("","var __p__ = '', data = __i__.d;",""),e.BLOCKCODE,t("","return __p__;","")].join("")},hn=function(e){var t=xt;return[t("","if ("),e.IFCOND,t(")","{","")].join("")},mn=function(e){var t=xt;return[t("","}","else if ("),e.ELIFCOND,t(")","{","")].join("")},vn=function(){var e=xt;return e("","}","else","{","")},On=function(){var e=xt;return e("","}","")},En=function(e,t){var n=xt;return 2===t?[n("","var "),e._O," = ",e.O,", ",e._OK," = Contemplate.keys(",e._O,n(");","if ("),e._OK," && ",e._OK,n(".length)","{","    var "),e._K,", ",e._V,", ",e._L," = ",e._OK,".length",n(";","    for ("),e._K,"=0; ",e._K,"<",e._L,"; ",e._K,n("++)","    {","        "),e.ASSIGN1,n("","        ","")].join(""):[n("","var "),e._O," = Contemplate.values(",e.O,n(");","if ("),e._O," && ",e._O,n(".length)","{","    var "),e._K,", ",e._V,", ",e._L," = ",e._O,".length",n(";","    for ("),e._K,"=0; ",e._K,"<",e._L,"; ",e._K,n("++)","    {","        "),e.ASSIGN1,n("","        ","")].join("")},Cn=function(e,t){var n=xt;return 2===t?n("","    }","}","else","{  ",""):n("","    }","}","else","{  ","")},bn=function(e,t){var n=xt;return 3===t?n("","    }","}",""):2===t?n("","    }","}",""):n("","}","")},Tn=function(e,t){var n=xt;return 1===t?"return '';":[n("","var __p__ = '', data = __i__.d;",""),e.FCODE,n("","return __p__;","")].join("")},An=function(e,t){var n=xt;return 1===t?"__p__ = '';":[n("","__i__.d = data;",""),e.RCODE,n("","")].join("")},yn=function(e,t,n){var r=e.tpl,u=e.merge,i=function(t,n){var i=null,o=null,l=null;this.id=null,this.d=null,t&&(this.id=t,i=n),this.setId=function(e){return e&&(this.id=e),this},this.extend=function(e){return o=e&&e.substr?r(e):e,this},this.setRenderFunction=function(e){return i=e,this},this.setBlocks=function(e){return l||(l={}),l=u(l,e),this},this.renderBlock=function(t,n){return n||(n=this),l&&l[t]?l[t](e,n):o?o.renderBlock(t,n):""},this.render=function(t,n){var r="";return n||(n=this),o?r=o.render(t,n):i&&(n.d=t,r=i(e,n)),this.d=null,r}};return new i(t,n)};return _={VERSION:g,CACHE_TO_DISK_NONE:0,CACHE_TO_DISK_AUTOUPDATE:2,CACHE_TO_DISK_NOUPDATE:4,ENCODING:"utf8",init:function(){R||(ut=[],St.specials=new RegExp("[\\n\\r\\v\\t]","g"),St.replacements=new RegExp("\\t[ ]*(.*?)[ ]*\\v","g"),St.controls=new RegExp("\\t[ ]*%("+wt.join("|")+")\\b[ ]*\\((.*)\\)","g"),St.controls2=new RegExp("%("+wt.join("|")+")\\b[ ]*\\((.*)\\)","g"),St.functions=new RegExp("%("+Dt.join("|")+")\\b","g"),tt=et,X="'; "+nt,Z=nt+"__p__ += '",R=!0)},addPlugin:function(e,t){e&&t&&(Nt[e]=!0,_["plugin_"+e]=t)},setPrefixCode:function(e){e&&(Q=""+e)},setLocaleStrings:function(e){F=_.merge(F,e)},clearLocaleStrings:function(){F={}},setPlurals:function(e){if(e){for(var t in e)null==e[t]&&(e[t]=t+"s");P=_.merge(P,e)}},clearPlurals:function(){P={}},setTemplateSeparators:function(e){e&&(e.left&&(J=""+e.left),e.right&&(W=""+e.right))},setPreserveLines:function(e){arguments.length<1&&(e=!0),tt=e?et:""},setCacheDir:function(e){G=s(e,"/")+"/"},setCacheMode:function(e){$=N?e:_.CACHE_TO_DISK_NONE},setSyncMode:function(e){B=!e},clearCache:function(e){Y={},e&&(z={})},add:function(e,t){if("object"==typeof e){for(var n in e)j(e[n])&&(e[n][0]&&(V[n]=e[n][0]),delete e[n]);q=_.merge(q,e)}else e&&t&&(q[e]=t)},addInline:function(e,t){"object"==typeof e?V=_.merge(V,e):e&&t&&(V[e]=t)},tpl:function(e,t,n){n=kt({autoUpdate:!1,refresh:!1,escape:!0,separators:null},n),rt=!1===n.escape?!1:!0,(n.refresh||!Y[e])&&(Y[e]=fn(e,n));var r=Y[e];return t&&"object"==typeof t?r.render(t):r},html:function(e){return n(e,"ENT_COMPAT","UTF-8")},url:r,count:u,haskey:function(t){var n=S(t);if(!t||"[object Array]"!=n&&"[object Object]"!=n)return!1;var r,u,i,o=D(arguments);for(o.shift(),r=o.length,i=t,u=0;r>u;u++){if(e===i[o[u]])return!1;i=i[o[u]]}return!0},q:function(e){return"'"+e+"'"},dq:function(e){return'"'+e+'"'},s:function(e){return v(e)},n:function(e){return C(e,10)},f:function(e){return b(e,10)},addslashes:function(e){return(e+"").replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0")},stripslashes:function(e){return(e+"").replace(/\\(.?)/g,function(e,t){switch(t){case"\\":return"\\";case"0":return"\x00";case"":return"";default:return t}})},concat:function(){return D(arguments).join("")},trim:c,ltrim:a,rtrim:s,ucfirst:function(e){return e[0].toUpperCase()+e.substr(1)},lcfirst:function(e){return e[0].toLowerCase()+e.substr(1)},lowercase:function(e){return e.toLowerCase()},uppercase:function(e){return e.toUpperCase()},camelcase:function(e,t,n){return t=t||"_",n?e.split(t).map(_.ucfirst).join(""):_.lcfirst(e.split(t).map(_.ucfirst).join(""))},snakecase:function(e,t){return t=t||"_",e.replace(/([A-Z])/g,t+"$1").toLowerCase()},sprintf:l,time:f,date:function(e,t){return t||(t=f()),d(e,t)},ldate:function(e,t){return t||(t=f()),p(F,e,t)},locale:function(e){return w(F,e)?F[e]:e},pluralise:function(e,t){return P[e]&&1!==t?P[e]:e},uuid:function(e){return[e||"UUID",++Ot,f()].join("_")},htmltable:function(e,t){e=_.merge({},e),t=_.merge({},t||{});var n,r,u,o,l,a,s,c,f,d="",p="",g="",h="",v=[],O=!1;if(d="<table",t.id&&(d+=" id='"+t.id+"'"),t["class"]&&(d+=" class='"+t["class"]+"'"),t.style&&(d+=" style='"+t.style+"'"),t.data)for(n in t.data)_.hasOwn(t.data,n)&&(d+=" data-"+n+"='"+t.data[n]+"'");d+=">",p="",(t.header||t.footer)&&(p="<td>"+(_.keys(e)||[]).join("</td><td>")+"</td>"),g="",t.header&&(g="<thead><tr>"+p+"</tr></thead>"),h="",t.footer&&(h="<tfoot><tr>"+p+"</tr></tfoot>"),d+=g,v=[],l=_.values(e)||[];for(r in l)if(_.hasOwn(l,r))for(a=l[r],i(a)||(a=[a]),s=_.values(a)||[],u=0,o=s.length;o>u;u++)v[u]||(v[u]=new m(o)),v[u][r]=s[u];for(c=t.odd?t.odd:"odd",f=t.even?t.even:"even",O=!1,r=0,o=v.length;o>r;r++)d+=O?"<tr class='"+c+"'><td>"+v[r].join("</td><td>")+"</td></tr>":"<tr class='"+f+"'><td>"+v[r].join("</td><td>")+"</td></tr>",O=!O;return v=null,d+=h,d+="</table>"},htmlselect:function(e,t){e=_.merge({},e),t=_.merge({},t||{});var n,r,u,l,a="";if(a="<select",t.multiple&&(a+=" multiple"),t.disabled&&(a+=" disabled='disabled'"),t.name&&(a+=" name='"+t.name+"'"),t.id&&(a+=" id='"+t.id+"'"),t["class"]&&(a+=" class='"+t["class"]+"'"),t.style&&(a+=" style='"+t.style+"'"),t.data)for(n in t.data)_.hasOwn(t.data,n)&&(a+=" data-"+n+"='"+t.data[n]+"'");a+=">",t.selected?(i(t.selected)||(t.selected=[t.selected]),t.selected=o(t.selected)):t.selected={},t.optgroups&&(i(t.optgroups)||(t.optgroups=[t.optgroups]),t.optgroups=o(t.optgroups));for(n in e)if(_.hasOwn(e,n))if(u=e[n],t.optgroups&&t.optgroups[n]){a+="<optgroup label='"+n+"'>";for(r in u)_.hasOwn(u,r)&&(l=u[r],t.use_key?l=r:t.use_value&&(r=l),a+=_.hasOwn(t.selected,r)?"<option value='"+r+"' selected='selected'>"+l+"</option>":"<option value='"+r+"'>"+l+"</option>");a+="</optgroup>"}else t.use_key?u=n:t.use_value&&(n=u),a+=t.selected[n]?"<option value='"+n+"' selected='selected'>"+u+"</option>":"<option value='"+n+"'>"+u+"</option>";return a+="</select>"},getTemplateContents:Kt,hasOwn:function(e,t){return e&&w(e,t)},keys:function(e){return e?E(e):null},values:function(e){if(e){if(e instanceof m)return e;var t,n=[];for(t in e)w(e,t)&&n.push(e[t]);return n}return null},items:function(e){return e?e:null},merge:kt,data:function(e){if(j(e))return e.slice();var t,n,r={};for(t in e)w(e,t)&&(n=t,r[n]=e[t]);return r}},_.now=_.time,_.l=_.locale,_.init(),_});</script>

<!--External Template Definitions-->
<script type="text/x-kendo-template" id="kendoUIextTemplate"><div><h1 class='header'>#= data.header #</h1><h2 class='header2'>#= data.header2 #</h2><h3 class='header3'>#= data.header3 #</h3><h4 class='header4'>#= data.header4 #</h4><h5 class='header5'>#= data.header5 #</h5><h6 class='header6'>#= data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#= data.list[i] #</li># } #</ul></div></script>

<script type="text/x-contemplate" id="contemplateextTemplate">
<# #>
<div><h1 class='header'><# $header #></h1><h2 class='header2'><# $header2 #></h2><h3 class='header3'><# $header3 #></h3><h4 class='header4'><# $header4 #></h4><h5 class='header5'><# $header5 #></h5><h6 class='header6'><# $header6 #></h6><ul class='list'><# %for($list as $item) #><li class='item'><# $item #></li><# %endfor() #></ul></div>
</script>

<script>
  window.sharedVariables = {
    header: "Header",
    header2: "Header2",
    header3: "Header3",
    header4: "Header4",
    header5: "Header5",
    header6: "Header6",
    list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
  };

  window.mustacheTemplate = "<div><h1 class='header'>{{{header}}}</h1><h2 class='header2'>{{{header2}}}</h2><h3 class='header3'>{{{header3}}}</h3><h4 class='header4'>{{{header4}}}</h4><h5 class='header5'>{{{header5}}}</h5><h6 class='header6'>{{{header6}}}</h6><ul class='list'>{{#list}}<li class='item'>{{{.}}}</li>{{/list}}</ul></div>";

  window.underscoreTemplate = _.template("<div><h1 class='header'><%= header %></h1><h2 class='header2'><%= header2 %></h2><h3 class='header3'><%= header3 %></h3><h4 class='header4'><%= header4 %></h4><h5 class='header5'><%= header5 %></h5><h6 class='header6'><%= header6 %></h6><ul class='list'><% for (var i = 0, l = list.length; i < l; i++) { %><li class='item'><%= list[i] %></li><% } %></ul></div>");

  window.handlebarsTemplate = Handlebars.compile("<div><h1 class='header'>{{header}}</h1><h2 class='header2'>{{header2}}</h2><h3 class='header3'>{{header3}}</h3><h4 class='header4'>{{header4}}</h4><h5 class='header5'>{{header5}}</h5><h6 class='header6'>{{header6}}</h6><ul class='list'>{{#each list}}<li class='item'>{{this}}</li>{{/each}}</ul></div>");


  Handlebars.template((function(){var a=Handlebars.template,b=Handlebars.templates=Handlebars.templates||{};b["template-handlebars.html"]=a(function(a,b,c,d,e){function k(a,b){var c="";return c+="<li class='item'>"+i(typeof a===h?a.apply(a):a)+"</li>",c}this.compilerInfo=[2,">= 1.0.0-rc.3"],c=c||a.helpers,e=e||{};var f="",g,h="function",i=this.escapeExpression,j=this;f+="<div><h1 class='header'>",(g=c.header)?g=g.call(b,{hash:{},data:e}):(g=b.header,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h1><h2 class='header2'>",(g=c.header2)?g=g.call(b,{hash:{},data:e}):(g=b.header2,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h2><h3 class='header3'>",(g=c.header3)?g=g.call(b,{hash:{},data:e}):(g=b.header3,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h3><h4 class='header4'>",(g=c.header4)?g=g.call(b,{hash:{},data:e}):(g=b.header4,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h4><h5 class='header5'>",(g=c.header5)?g=g.call(b,{hash:{},data:e}):(g=b.header5,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h5><h6 class='header6'>",(g=c.header6)?g=g.call(b,{hash:{},data:e}):(g=b.header6,g=typeof g===h?g.apply(b):g),f+=i(g)+"</h6><ul class='list'>",g=c.each.call(b,b.list,{hash:{},inverse:j.noop,fn:j.program(1,k,e),data:e});if(g||g===0)f+=g;return f+="</ul></div>",f})})());

  //Resig Template Function (modified to support ')
  function tmpl(str) {
              var strFunc =
              "var p=[];" +
                          "with(obj){p.push('" +
  
              str.replace(/[\r\t\n]/g, " ")
                 .replace(/'(?=[^#]*#>)/g, "\t")
                 .split("'").join("\\'")
                 .split("\t").join("'")
                 .replace(/<#=(.+?)#>/g, "',$1,'")
                 .split("<#").join("');")
                 .split("#>").join("p.push('")
                 + "');}return p.join('');";
  
              return new Function("obj", strFunc);
          }
  
  window.resig = tmpl("<div><h1 class='header'><#= header #></h1><h2 class='header2'><#= header2 #></h2><h3 class='header3'><#= header3 #></h3><h4 class='header4'><#= header4 #></h4><h5 class='header5'><#= header5 #></h5><h6 class='header6'><#= header6 #></h6><ul class='list'><# for (var i = 0, l = list.length; i < l; i++) { #><li class='item'><#= list[i] #></li><# } #></ul></div>");
  
  //Resig modified template function (no "with" block)
  function tmpl2(str) {
              var strFunc =
              "var p=[];" +
                          "p.push('" +
  
              str.replace(/[\r\t\n]/g, " ")
                 .replace(/'(?=[^#]*#>)/g, "\t")
                 .split("'").join("\\'")
                 .split("\t").join("'")
                 .replace(/<#=(.+?)#>/g, "',$1,'")
                 .split("<#").join("');")
                 .split("#>").join("p.push('")
                 + "');return p.join('');";
  
              return new Function("data", strFunc);
          }
  
  window.resig2 = tmpl2("<div><h1 class='header'><#= data.header #></h1><h2 class='header2'><#= data.header2 #></h2><h3 class='header3'><#= data.header3 #></h3><h4 class='header4'><#= data.header4 #></h4><h5 class='header5'><#= data.header5 #></h5><h6 class='header6'><#= data.header6 #></h6><ul class='list'><# for (var i = 0, l = data.list.length; i < l; i++) { #><li class='item'><#= data.list[i] #></li><# } #></ul></div>");

  window.kendouiTemplate = kendo.template("<div><h1 class='header'>#= data.header #</h1><h2 class='header2'>#= data.header2 #</h2><h3 class='header3'>#= data.header3 #</h3><h4 class='header4'>#= data.header4 #</h4><h5 class='header5'>#= data.header5 #</h5><h6 class='header6'>#= data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#= data.list[i] #</li># } #</ul></div>", {useWithBlock: true});
  
  window.kendouiTemplate2 = kendo.template("<div><h1 class='header'>#= data.header #</h1><h2 class='header2'>#= data.header2 #</h2><h3 class='header3'>#= data.header3 #</h3><h4 class='header4'>#= data.header4 #</h4><h5 class='header5'>#= data.header5 #</h5><h6 class='header6'>#= data.header6 #</h6><ul class='list'># for (var i = 0, l = data.list.length; i < l; i++) { #<li class='item'>#= data.list[i] #</li># } #</ul></div>", {useWithBlock: false});
  
  //Use external template definition
  window.kendoUIAlt1 = kendo.template($("#kendoUIextTemplate").html());
  window.kendoUIAlt2 = kendo.template($("#kendoUIextTemplate").html(), {useWithBlock: false});

  //Use external template definition
  Contemplate.add({
    'test': "#contemplateextTemplate"
  })
  window.contemplateTpl = Contemplate.tpl( 'test' );

  window.dustTemplatePrecompiled = (function(){dust.register("dustTemplatePrecompiled",body_0);function body_0(chk,ctx){return chk.write("<div><h1 class='header'>").reference(ctx.get("header"),ctx,"h").write("</h1><h2 class='header2'>").reference(ctx.get("header2"),ctx,"h").write("</h2><h3 class='header3'>").reference(ctx.get("header3"),ctx,"h").write("</h3><h4 class='header4'>").reference(ctx.get("header4"),ctx,"h").write("</h4><h5 class='header5'>").reference(ctx.get("header5"),ctx,"h").write("</h5><h6 class='header6'>").reference(ctx.get("header6"),ctx,"h").write("</h6><ul class='list'>").section(ctx.get("list"),ctx,{"block":body_1},null).write("</ul></div>");}function body_1(chk,ctx){return chk.write("<li class='item'>").reference(ctx.getPath(true,[]),ctx,"h").write("</li>");}return body_0;})();

  window.dustTemplate2 = function(content) {
    dust.loadSource(dustTemplatePrecompiled, "dustTemplatePrecompiled");
    dust.render("dustTemplatePrecompiled", content, function() {});
  };

  window.dustTemplatePrecompiledCached = (function(){dust.register("dustTemplatePrecompiledCached",body_0);function body_0(chk,ctx){return chk.write("<div><h1 class='header'>").reference(ctx.get("header"),ctx,"h").write("</h1><h2 class='header2'>").reference(ctx.get("header2"),ctx,"h").write("</h2><h3 class='header3'>").reference(ctx.get("header3"),ctx,"h").write("</h3><h4 class='header4'>").reference(ctx.get("header4"),ctx,"h").write("</h4><h5 class='header5'>").reference(ctx.get("header5"),ctx,"h").write("</h5><h6 class='header6'>").reference(ctx.get("header6"),ctx,"h").write("</h6><ul class='list'>").section(ctx.get("list"),ctx,{"block":body_1},null).write("</ul></div>");}function body_1(chk,ctx){return chk.write("<li class='item'>").reference(ctx.getPath(true,[]),ctx,"h").write("</li>");}return body_0;})();

    dust.loadSource(dustTemplatePrecompiledCached, "dustTemplatePrecompiledCached");

  window.dustTemplate3 = function(content) {
    dust.render("dustTemplatePrecompiledCached", content, function() {});
  };

 $(document.body).append('<ul id="tempoTemplate"> <li data-template> {{header}} {{header2}} {{header3}} {{header4}} {{header5}} {{header6}} <ul><li >{{list}}</li></ul></li></ul> ');


  var tempoPrepared = Tempo.prepare('tempoTemplate');
 tempoTemplate = function(data) { tempoPrepared.render(data); }
     
     tempoTemplate()

  window.hoganCompile = Hogan.compile("<div><h1 class='header'>{{{header}}}</h1><h2>class='header2'>{{{header2}}}</h2><h3 class='header3'>{{{header3}}}</h3><h4 class='header4'>{{{header4}}}</h4><h5 class='header5'>{{{header5}}}</h5><h6 class='header6'>{{{header6}}}</h6><ul class='list'>{{#list}}<li class='item'>{{{.}}}</li>{{/list}}</ul></div>");

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
mustache.js
Mustache.render(mustacheTemplate, sharedVariables);
ready
underscore.js
underscoreTemplate(sharedVariables);
ready
handlebar.js
handlebarsTemplate(sharedVariables);
ready
handlebar.js (precompiled)
Handlebars.templates["template-handlebars.html"](sharedVariables);
ready
dust.js (precompiled)
dustTemplate2(sharedVariables);
ready
dust.js (precompiled, cached)
dustTemplate3(sharedVariables);
ready
TempoJs
tempoTemplate(sharedVariables);
ready
Hogan.js
hoganCompile.render(sharedVariables);
ready
Kendo UI Templates (Default)
kendouiTemplate(sharedVariables);
ready
Kendo UI Templates (No "with" block)
kendouiTemplate2(sharedVariables);
ready
Resig Micro Templates (modified)
resig(sharedVariables);
ready
Resig Micro Templates (No "with" block)
resig2(sharedVariables);
ready
Contemplate 0.6.6 rev.2 (Compiled)
contemplateTpl.render(sharedVariables);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.