jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
A limited comparison of some popular JavaScript templating engines on a short template: 6 header tags, and 10 list items. Compared templating engines:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<!-- jQuery.browser -->
<script>
/*!
* jQuery Browser Plugin 0.0.5
* https://github.com/gabceb/jquery-browser-plugin
*
* Original jquery-browser code Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
* http://jquery.org/license
*
* Modifications Copyright 2013 Gabriel Cebrian
* https://github.com/gabceb
*
* Released under the MIT license
*
* Date: 14-11-2013
*/!function(a,b){"use strict";var c,d;if(a.uaMatch=function(a){a=a.toLowerCase();var b=/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(iphone)/.exec(a)||/(android)/.exec(a)||/(windows phone)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||[];return{browser:b[3]||b[1]||"",version:b[2]||"0",platform:c[0]||""}},c=a.uaMatch(b.navigator.userAgent),d={},c.browser&&(d[c.browser]=!0,d.version=c.version,d.versionNumber=parseFloat(c.version,10)),c.platform&&(d[c.platform]=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv){var e="msie";c.browser=e,d[e]=!0}if(d.opr){var f="opera";c.browser=f,d[f]=!0}d.name=c.browser,d.platform=c.platform,a.browser=d}(jQuery,window);
</script>
<!-- /jQuery.browser -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<!-- Underscore.string -->
<script>
// Underscore.string
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
// Underscore.string is freely distributable under the terms of the MIT license.
// Documentation: https://github.com/epeli/underscore.string
// Some code is borrowed from MooTools and Alexandru Marasteanu.
// Version '2.3.0'
!function(root, String){
'use strict';
// Defining helper functions.
var nativeTrim = String.prototype.trim;
var nativeTrimRight = String.prototype.trimRight;
var nativeTrimLeft = String.prototype.trimLeft;
var parseNumber = function(source) { return source * 1 || 0; };
var strRepeat = function(str, qty){
if (qty < 1) return '';
var result = '';
while (qty > 0) {
if (qty & 1) result += str;
qty >>= 1, str += str;
}
return result;
};
var slice = [].slice;
var defaultToWhiteSpace = function(characters) {
if (characters == null)
return '\\s';
else if (characters.source)
return characters.source;
else
return '[' + _s.escapeRegExp(characters) + ']';
};
var escapeChars = {
lt: '<',
gt: '>',
quot: '"',
apos: "'",
amp: '&'
};
var reversedEscapeChars = {};
for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
// sprintf() for JavaScript 0.7-beta1
// http://www.diveintojavascript.com/projects/javascript-sprintf
//
// Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
// All rights reserved.
var sprintf = (function() {
function get_type(variable) {
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
}
var str_repeat = strRepeat;
var str_format = function() {
if (!str_format.cache.hasOwnProperty(arguments[0])) {
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
}
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
};
str_format.format = function(parse_tree, argv) {
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
for (i = 0; i < tree_length; i++) {
node_type = get_type(parse_tree[i]);
if (node_type === 'string') {
output.push(parse_tree[i]);
}
else if (node_type === 'array') {
match = parse_tree[i]; // convenience purposes only
if (match[2]) { // keyword argument
arg = argv[cursor];
for (k = 0; k < match[2].length; k++) {
if (!arg.hasOwnProperty(match[2][k])) {
throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
}
arg = arg[match[2][k]];
}
} else if (match[1]) { // positional argument (explicit)
arg = argv[match[1]];
}
else { // positional argument (implicit)
arg = argv[cursor++];
}
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
throw new Error(sprintf('[_.sprintf] expecting number but found %s', get_type(arg)));
}
switch (match[8]) {
case 'b': arg = arg.toString(2); break;
case 'c': arg = String.fromCharCode(arg); break;
case 'd': arg = parseInt(arg, 10); break;
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
case 'o': arg = arg.toString(8); break;
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
case 'u': arg = Math.abs(arg); break;
case 'x': arg = arg.toString(16); break;
case 'X': arg = arg.toString(16).toUpperCase(); break;
}
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
pad_length = match[6] - String(arg).length;
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
output.push(match[5] ? arg + pad : pad + arg);
}
}
return output.join('');
};
str_format.cache = {};
str_format.parse = function(fmt) {
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
while (_fmt) {
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
parse_tree.push(match[0]);
}
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
parse_tree.push('%');
}
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
if (match[2]) {
arg_names |= 1;
var field_list = [], replacement_field = match[2], field_match = [];
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else {
throw new Error('[_.sprintf] huh?');
}
}
}
else {
throw new Error('[_.sprintf] huh?');
}
match[2] = field_list;
}
else {
arg_names |= 2;
}
if (arg_names === 3) {
throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported');
}
parse_tree.push(match);
}
else {
throw new Error('[_.sprintf] huh?');
}
_fmt = _fmt.substring(match[0].length);
}
return parse_tree;
};
return str_format;
})();
// Defining underscore.string
var _s = {
VERSION: '2.3.0',
isBlank: function(str){
if (str == null) str = '';
return (/^\s*$/).test(str);
},
stripTags: function(str){
if (str == null) return '';
return String(str).replace(/<\/?[^>]+>/g, '');
},
capitalize : function(str){
str = str == null ? '' : String(str);
return str.charAt(0).toUpperCase() + str.slice(1);
},
chop: function(str, step){
if (str == null) return [];
str = String(str);
step = ~~step;
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
},
clean: function(str){
return _s.strip(str).replace(/\s+/g, ' ');
},
count: function(str, substr){
if (str == null || substr == null) return 0;
return String(str).split(substr).length - 1;
},
chars: function(str) {
if (str == null) return [];
return String(str).split('');
},
swapCase: function(str) {
if (str == null) return '';
return String(str).replace(/\S/g, function(c){
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
});
},
escapeHTML: function(str) {
if (str == null) return '';
return String(str).replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; });
},
unescapeHTML: function(str) {
if (str == null) return '';
return String(str).replace(/\&([^;]+);/g, function(entity, entityCode){
var match;
if (entityCode in escapeChars) {
return escapeChars[entityCode];
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
return String.fromCharCode(parseInt(match[1], 16));
} else if (match = entityCode.match(/^#(\d+)$/)) {
return String.fromCharCode(~~match[1]);
} else {
return entity;
}
});
},
escapeRegExp: function(str){
if (str == null) return '';
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
},
splice: function(str, i, howmany, substr){
var arr = _s.chars(str);
arr.splice(~~i, ~~howmany, substr);
return arr.join('');
},
insert: function(str, i, substr){
return _s.splice(str, i, 0, substr);
},
include: function(str, needle){
if (needle === '') return true;
if (str == null) return false;
return String(str).indexOf(needle) !== -1;
},
join: function() {
var args = slice.call(arguments),
separator = args.shift();
if (separator == null) separator = '';
return args.join(separator);
},
lines: function(str) {
if (str == null) return [];
return String(str).split("\n");
},
reverse: function(str){
return _s.chars(str).reverse().join('');
},
startsWith: function(str, starts){
if (starts === '') return true;
if (str == null || starts == null) return false;
str = String(str); starts = String(starts);
return str.length >= starts.length && str.slice(0, starts.length) === starts;
},
endsWith: function(str, ends){
if (ends === '') return true;
if (str == null || ends == null) return false;
str = String(str); ends = String(ends);
return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
},
succ: function(str){
if (str == null) return '';
str = String(str);
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length-1) + 1);
},
titleize: function(str){
if (str == null) return '';
return String(str).replace(/(?:^|\s)\S/g, function(c){ return c.toUpperCase(); });
},
camelize: function(str){
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, c){ return c.toUpperCase(); });
},
underscored: function(str){
return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
},
dasherize: function(str){
return _s.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
},
classify: function(str){
return _s.titleize(String(str).replace(/_/g, ' ')).replace(/\s/g, '');
},
humanize: function(str){
return _s.capitalize(_s.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
},
trim: function(str, characters){
if (str == null) return '';
if (!characters && nativeTrim) return nativeTrim.call(str);
characters = defaultToWhiteSpace(characters);
return String(str).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
},
ltrim: function(str, characters){
if (str == null) return '';
if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
characters = defaultToWhiteSpace(characters);
return String(str).replace(new RegExp('^' + characters + '+'), '');
},
rtrim: function(str, characters){
if (str == null) return '';
if (!characters && nativeTrimRight) return nativeTrimRight.call(str);
characters = defaultToWhiteSpace(characters);
return String(str).replace(new RegExp(characters + '+$'), '');
},
truncate: function(str, length, truncateStr){
if (str == null) return '';
str = String(str); truncateStr = truncateStr || '...';
length = ~~length;
return str.length > length ? str.slice(0, length) + truncateStr : str;
},
/**
* _s.prune: a more elegant version of truncate
* prune extra chars, never leaving a half-chopped word.
* @author github.com/rwz
*/
prune: function(str, length, pruneStr){
if (str == null) return '';
str = String(str); length = ~~length;
pruneStr = pruneStr != null ? String(pruneStr) : '...';
if (str.length <= length) return str;
var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
if (template.slice(template.length-2).match(/\w\w/))
template = template.replace(/\s*\S+$/, '');
else
template = _s.rtrim(template.slice(0, template.length-1));
return (template+pruneStr).length > str.length ? str : str.slice(0, template.length)+pruneStr;
},
words: function(str, delimiter) {
if (_s.isBlank(str)) return [];
return _s.trim(str, delimiter).split(delimiter || /\s+/);
},
pad: function(str, length, padStr, type) {
str = str == null ? '' : String(str);
length = ~~length;
var padlen = 0;
if (!padStr)
padStr = ' ';
else if (padStr.length > 1)
padStr = padStr.charAt(0);
switch(type) {
case 'right':
padlen = length - str.length;
return str + strRepeat(padStr, padlen);
case 'both':
padlen = length - str.length;
return strRepeat(padStr, Math.ceil(padlen/2)) + str
+ strRepeat(padStr, Math.floor(padlen/2));
default: // 'left'
padlen = length - str.length;
return strRepeat(padStr, padlen) + str;
}
},
lpad: function(str, length, padStr) {
return _s.pad(str, length, padStr);
},
rpad: function(str, length, padStr) {
return _s.pad(str, length, padStr, 'right');
},
lrpad: function(str, length, padStr) {
return _s.pad(str, length, padStr, 'both');
},
sprintf: sprintf,
vsprintf: function(fmt, argv){
argv.unshift(fmt);
return sprintf.apply(null, argv);
},
toNumber: function(str, decimals) {
if (str == null || str == '') return 0;
str = String(str);
var num = parseNumber(parseNumber(str).toFixed(~~decimals));
return num === 0 && !str.match(/^0+$/) ? Number.NaN : num;
},
numberFormat : function(number, dec, dsep, tsep) {
if (isNaN(number) || number == null) return '';
number = number.toFixed(~~dec);
tsep = tsep || ',';
var parts = number.split('.'), fnums = parts[0],
decimals = parts[1] ? (dsep || '.') + parts[1] : '';
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals;
},
strRight: function(str, sep){
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.indexOf(sep);
return ~pos ? str.slice(pos+sep.length, str.length) : str;
},
strRightBack: function(str, sep){
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.lastIndexOf(sep);
return ~pos ? str.slice(pos+sep.length, str.length) : str;
},
strLeft: function(str, sep){
if (str == null) return '';
str = String(str); sep = sep != null ? String(sep) : sep;
var pos = !sep ? -1 : str.indexOf(sep);
return ~pos ? str.slice(0, pos) : str;
},
strLeftBack: function(str, sep){
if (str == null) return '';
str += ''; sep = sep != null ? ''+sep : sep;
var pos = str.lastIndexOf(sep);
return ~pos ? str.slice(0, pos) : str;
},
toSentence: function(array, separator, lastSeparator, serial) {
separator = separator || ', '
lastSeparator = lastSeparator || ' and '
var a = array.slice(), lastMember = a.pop();
if (array.length > 2 && serial) lastSeparator = _s.rtrim(separator) + lastSeparator;
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
},
toSentenceSerial: function() {
var args = slice.call(arguments);
args[3] = true;
return _s.toSentence.apply(_s, args);
},
slugify: function(str) {
if (str == null) return '';
var from = "ąàáäâãåæćęèéëêìíïîłńòóöôõøùúüûñçżź",
to = "aaaaaaaaceeeeeiiiilnoooooouuuunczz",
regex = new RegExp(defaultToWhiteSpace(from), 'g');
str = String(str).toLowerCase().replace(regex, function(c){
var index = from.indexOf(c);
return to.charAt(index) || '-';
});
return _s.dasherize(str.replace(/[^\w\s-]/g, ''));
},
surround: function(str, wrapper) {
return [wrapper, str, wrapper].join('');
},
quote: function(str) {
return _s.surround(str, '"');
},
exports: function() {
var result = {};
for (var prop in this) {
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue;
result[prop] = this[prop];
}
return result;
},
repeat: function(str, qty, separator){
if (str == null) return '';
qty = ~~qty;
// using faster implementation if separator is not needed;
if (separator == null) return strRepeat(String(str), qty);
// this one is about 300x slower in Google Chrome
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
return repeat.join(separator);
},
levenshtein: function(str1, str2) {
if (str1 == null && str2 == null) return 0;
if (str1 == null) return String(str2).length;
if (str2 == null) return String(str1).length;
str1 = String(str1); str2 = String(str2);
var current = [], prev, value;
for (var i = 0; i <= str2.length; i++)
for (var j = 0; j <= str1.length; j++) {
if (i && j)
if (str1.charAt(j - 1) === str2.charAt(i - 1))
value = prev;
else
value = Math.min(current[j], current[j - 1], prev) + 1;
else
value = i + j;
prev = current[j];
current[j] = value;
}
return current.pop();
}
};
// Aliases
_s.strip = _s.trim;
_s.lstrip = _s.ltrim;
_s.rstrip = _s.rtrim;
_s.center = _s.lrpad;
_s.rjust = _s.lpad;
_s.ljust = _s.rpad;
_s.contains = _s.include;
_s.q = _s.quote;
// CommonJS module is defined
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
// Export module
module.exports = _s;
}
exports._s = _s;
} else if (typeof define === 'function' && define.amd) {
// Register as a named module with AMD.
define('underscore.string', [], function() {
return _s;
});
} else {
// Integrate with Underscore.js if defined
// or create our own underscore object.
root._ = root._ || {};
root._.string = root._.str = _s;
}
}(this, String);
</script>
<!-- /Underscore.string -->
<script src="https://ajax.cdnjs.com/ajax/libs/mustache.js/0.3.0/mustache.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.2/handlebars.min.js"></script>
<script src="https://cdn.kendostatic.com/2012.1.322/js/kendo.all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.6.3/coffee-script.min.js"></script>
<script src="https://borismoore.github.com/jsrender/jsrender.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hogan.js/2.0.0/hogan.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dustjs-linkedin/2.0.0/dust-full.js"></script>
<script src="https://www.javascriptoo.com//application/html/js/olado/doT/doT.min.js"></script>
<script src="https://juicer.name/javascripts/juicer-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jade/0.27.7/jade.min.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/clientside-haml-js/5.1/haml.js"></script>-->
<!-- VASH -->
<script>
/**
* Vash - JavaScript Template Parser, v0.7.6-2
*
* https://github.com/kirbysayshi/vash
*
* Copyright (c) 2013 Andrew Petersen
* MIT License (LICENSE)
*/void 0,function(a){typeof define=="function"&&define.amd?define(a):typeof module=="object"&&module.exports?module.exports=a:window.vash=a}(function(a){function S(a,b,c){this.ast=a,this.originalMarkup=b||"",this.options=c||{},this.reQuote=/(['"])/gi,this.reEscapedQuote=/\\+(["'])/gi,this.reLineBreak=/\r?\n/gi,this.reHelpersName=/HELPERSNAME/g,this.reModelName=/MODELNAME/g,this.reOriginalMarkup=/ORIGINALMARKUP/g,this.buffer=[]}function N(a,b){this.options=b||{},this.tokens=a,this.ast=M(O),this.prevTokens=[],this.inCommentLine=!1}function L(a){this.input=this.originalInput=a.replace(/\r\n|\r/g,"\n"),this.lineno=1,this.charno=0}var b=a,c="AT",d="ASSIGN_OPERATOR",e="AT_COLON",f="AT_STAR_CLOSE",g="AT_STAR_OPEN",h="BACKSLASH",i="BRACE_CLOSE",j="BRACE_OPEN",k="CONTENT",l="DOUBLE_QUOTE",m="EMAIL",n="ESCAPED_QUOTE",o="FORWARD_SLASH",p="FUNCTION",q="HARD_PAREN_CLOSE",r="HARD_PAREN_OPEN",s="HTML_TAG_CLOSE",t="HTML_TAG_OPEN",u="HTML_TAG_VOID_OPEN",v="HTML_TAG_VOID_CLOSE",w="IDENTIFIER",x="KEYWORD",y="LOGICAL",z="NEWLINE",A="NUMERIC_CONTENT",B="OPERATOR",C="PAREN_CLOSE",D="PAREN_OPEN",E="PERIOD",F="SINGLE_QUOTE",G="TEXT_TAG_CLOSE",H="TEXT_TAG_OPEN",I="WHITESPACE",J={};J[g]=f,J[j]=i,J[l]=l,J[r]=q,J[D]=C,J[F]=F,J[e]=z,J[o]=o;var K=[m,/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:ca|co\.uk|com|edu|net|org))\b/,g,/^(@\*)/,f,/^(\*@)/,e,/^(@\:)/,c,/^(@)/,D,/^(\()/,C,/^(\))/,r,/^(\[)/,q,/^(\])/,j,/^(\{)/,i,/^(\})/,H,/^(<text>)/,G,/^(<\/text>)/,t,function(){var a=/^(<[a-zA-Z@]+?[^>]*?>)/,b=/([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/,c=/^(<[a-zA-Z@]+[^>]*?\s*\/\s*>)/,d=this.scan(c,u)||this.scan(a,t);d&&(this.spewIf(d,b),this.spewIf(d,/(@)/),this.spewIf(d,/(\/\s*>)/));return d},s,/^(<\/[^>@\b]+?>)/,v,/^(\/\s*>)/,E,/^(\.)/,z,function(){var a=this.scan(/^(\n)/,z);a&&(this.lineno++,this.charno=0);return a},I,/^(\s)/,p,/^(function)(?![\d\w])/,x,/^(case|catch|do|else|finally|for|function|goto|if|instanceof|return|switch|try|typeof|var|while|with)(?![\d\w])/,w,/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/,o,/^(\/)/,B,/^(===|!==|==|!==|>>>|<<|>>|>=|<=|>|<|\+|-|\/|\*|\^|%|\:|\?)/,d,/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=|=)/,y,/^(&&|\|\||&|\||\^)/,n,/^(\\+['"])/,h,/^(\\)/,l,/^(\")/,F,/^(\')/,A,/^([0-9]+)/,k,/^([^\s})@.]+?)/];L.prototype={scan:function(a,b){var c,d;if(c=a.exec(this.input)){this.input=this.input.substr(c[1].length),d={type:b,line:this.lineno,chr:this.charno,val:c[1]||"",toString:function(){return"["+this.type+" ("+this.line+","+this.chr+"): "+this.val+"]"}},this.charno+=c[0].length;return d}},spewIf:function(a,b){var c,d,e;a&&(c=b.exec(a.val),c&&(d=a.val.indexOf(c[1]),e=a.val.substring(d),this.input=e+this.input,this.charno-=e.length,a.val=a.val.substring(0,d)));return a},advance:function(){var a,b,c,d;for(a=0;a<K.length;a+=2){c=K[a+1],c.displayName=K[a],typeof c=="function"&&(d=c.call(this)),typeof c.exec=="function"&&(d=this.scan(c,K[a]));if(d)return d}}};var M=function(a){return new M.fn.init(a)};M.prototype.init=function(a){typeof a=="string"&&(this.mode=a),this.maxCheck()},M.fn=M.prototype.init.prototype=M.prototype,M.fn.vquery="yep",M.fn.constructor=M,M.fn.length=0,M.fn.parent=null,M.fn.mode=null,M.fn.tagName=null,M.fn.tagVoid=null,M.fn.beget=function(a,b){var c=M(a);c.parent=this,this.push(c),b&&(c.tagName=b),this.maxCheck();return c},M.fn.closest=function(a,b){var c=this;while(c)if(c.tagName!==b&&c.parent)c=c.parent;else break;return c},M.fn.pushFlatten=function(a){var b=a,c,d;while(b.length===1&&b[0].vquery)b=b[0];if(b.mode!==O)this.push(b);else for(c=0;c<b.length;c++)this.push(b[c]);this.maxCheck();return this},M.fn.push=function(a){M.isArray(a)?(a.vquery&&a.forEach(function(a){a.parent=this},this),Array.prototype.push.apply(this,a)):(a.vquery&&(a.parent=this),Array.prototype.push.call(this,a)),this.maxCheck();return this.length},M.fn.root=function(){var a=this;while(a&&a.parent&&(a=a.parent));return a},M.fn.toTreeString=function(){function c(d){var e,f;a.push(Array(b).join(" |")+" +"+d.mode+" "+(d.tagName||"")),b+=1,e=d.slice();while(f=e.shift())f.vquery===M.fn.vquery?c(f):a.push(Array(b).join(" |")+" "+(f?f.toString().replace(/(\r|\n)/g,""):"[empty]"));b-=1,a.push(Array(b).join(" |")+" -"+d.mode+" "+(d.tagName||""))}var a=[],b=1;c(this);return a.join("\n")},M.fn.maxCheck=function(a){if(this.length>=M.maxSize){var b=new Error;b.message="Maximum number of elements exceeded.\nThis is typically caused by an unmatched character or tag. Parse tree follows:\n"+this.toTreeString(),b.name="vQueryDepthException";throw b}},M.maxSize=1e5,M.fn.flatten=function(){var a;return this.reduce(function b(c,d,e,f){if(d.vquery){c.push({type:"META",val:"START"+d.mode,tagName:d.tagName}),a=d.reduce(b,c),a.push({type:"META",val:"END"+d.mode,tagName:d.tagName});return a}d.mode=f.mode,c.push(d);return c},[])},M.reconstitute=function(a){return a.reduce(function b(a,b,c,d){b.type==="META"?a=a.parent:(b.mode!==a.mode&&(a=a.beget(b.mode,b.tagName)),a.push(b));return a},M(O))},M.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"},M.extend=function(a){var b,c,d;for(c=1;c<arguments.length;c++){b=arguments[c];for(d in b)a[d]=b[d]}return a},M.takeMethodsFromArray=function(){var a=["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"],b=[],c;for(var d=0;d<a.length;d++){c=a[d];if(typeof b[c]=="function")M.fn[c]||function(a){M.fn[a]=function(){return b[a].apply(this,Array.prototype.slice.call(arguments,0))}}(c);else throw new Error("Vash requires ES5 array iteration methods, missing: "+c)}},M.takeMethodsFromArray();var O="PROGRAM",P="MARKUP",Q="BLOCK",R="EXPRESSION";N.prototype={parse:function(){var a,b,c,d;while(this.prevTokens.push(a),a=this.tokens.pop()){this.options.debugParser&&console.log(this.ast&&this.ast.mode,a.type,a.toString(),a.val);if(this.ast.mode===O||this.ast.mode===null)this.ast=this.ast.beget(this.options.initialMode||P),this.options.initialMode===R&&(this.ast=this.ast.beget(R));if(this.ast.mode===P){this.handleMKP(a);continue}if(this.ast.mode===Q){this.handleBLK(a);continue}if(this.ast.mode===R){this.handleEXP(a);continue}}this.ast=this.ast.root(),this.options.debugParser&&!this.options.initialMode&&(console.log(this.ast.toString()),console.log(this.ast.toTreeString()));return this.ast},exceptionFactory:function(a,b,c){b=="UNMATCHED"&&(a.name="UnmatchedCharacterError",this.ast=this.ast.root(),c&&(a.message="Unmatched "+c.type+" at line "+c.line+", character "+c.chr+". Value: "+c.val+"\n "+this.ast.toTreeString(),a.lineNumber=c.line));return a},advanceUntilNot:function(a){var b,c,d=[];while(c=this.tokens[this.tokens.length-1])if(c.type===a)b=this.tokens.pop(),d.push(b);else break;return d},advanceUntilMatched:function(a,b,c,d,e){var f=a,g=null,h=0,i=0,j=[];while(f){f.type===b?g&&g.type!==d&&b!==c||!g?h++:b===c&&g.type!==d&&i++:f.type===c&&(i++,g&&g.type===e&&i--),j.push(f);if(h===i)break;g=f,f=this.tokens.pop();if(!f)throw this.exceptionFactory(new Error,"UNMATCHED",a)}return j.reverse()},subParse:function(a,b,d){var e,f,g,h=M.extend({},this.options);h.initialMode=b,e=this.advanceUntilMatched(a,a.type,J[a.type],null,c),e.pop(),f=e.shift(),d||this.ast.push(a),g=new N(e,h),g.parse(),d&&(g.ast[0].unshift(a),g.ast[0].push(f)),this.ast.pushFlatten(g.ast),d||this.ast.push(f)},handleMKP:function(a){var b=this.tokens[this.tokens.length-1],d=this.tokens[this.tokens.length-2],i=null,k;switch(a.type){case g:this.advanceUntilMatched(a,g,f,c,c);break;case c:if(b){this.options.saveAT&&this.ast.push(a);switch(b.type){case D:case w:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(R);break;case x:case p:case j:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(Q);break;case c:case e:b.type="CONTENT",this.ast.push(this.tokens.pop());break;default:this.ast.push(this.tokens.pop())}}break;case H:case t:case u:i=a.val.match(/^<([^\/ >]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),this.ast.tagName?this.ast=this.ast.beget(P,i[1]):this.ast.tagName=i[1],a.type===u&&(this.ast.tagVoid=this.ast.tagName),(u===a.type||t===a.type||this.options.saveTextTag)&&this.ast.push(a);break;case G:case s:i=a.val.match(/^<\/([^>]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),k=this.ast.closest(P,i[1]),k!==null&&k.tagName===i[1]&&(this.ast=k),(s===a.type||this.options.saveTextTag)&&this.ast.push(a),this.ast.parent&&this.ast.parent.mode===Q&&(this.ast=this.ast.parent);break;case v:this.ast.tagVoid?(this.ast.push(a),this.ast=this.ast.parent):this.tokens.push(a);break;case h:a.val+="\\",this.ast.push(a);break;default:this.ast.push(a)}},handleBLK:function(a){var b=this.tokens[this.tokens.length-1],d,i,m,n,q,r,v;switch(a.type){case c:b.type!==c&&!this.inCommentLine?(this.tokens.push(a),this.ast=this.ast.beget(P)):(b.type=k,this.ast.push(b),this.tokens.pop());break;case g:this.advanceUntilMatched(a,g,f,c,c);break;case e:this.subParse(a,P,!0);break;case H:case G:case u:case t:case s:this.ast=this.ast.beget(P),this.tokens.push(a);break;case o:case F:case l:a.type===o&&b&&b.type===o&&(this.inCommentLine=!0),this.inCommentLine?this.ast.push(a):(n=this.advanceUntilMatched(a,a.type,J[a.type],h,h).map(function(a){a.type===c&&(a.type=k);return a}),this.ast.pushFlatten(n.reverse()));break;case z:this.inCommentLine&&(this.inCommentLine=!1),this.ast.push(a);break;case j:case D:d=this.options.favorText&&a.type===j?P:Q,this.subParse(a,d),n=this.advanceUntilNot(I),b=this.tokens[this.tokens.length-1],b&&b.type!==x&&b.type!==p&&b.type!==j&&a.type!==D?(this.tokens.push.apply(this.tokens,n.reverse()),this.ast=this.ast.parent):this.ast.push(n);break;default:this.ast.push(a)}},handleEXP:function(a){var b=null,e,f,g,i,k,m,n;switch(a.type){case x:case p:this.ast=this.ast.beget(Q),this.tokens.push(a);break;case I:case y:case d:case B:case A:this.ast.parent&&this.ast.parent.mode===R?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;case w:this.ast.push(a);break;case F:case l:this.ast.parent&&this.ast.parent.mode===R?(k=this.advanceUntilMatched(a,a.type,J[a.type],h,h),this.ast.pushFlatten(k.reverse())):(this.ast=this.ast.parent,this.tokens.push(a));break;case r:case D:m=this.prevTokens[this.prevTokens.length-1],b=this.tokens[this.tokens.length-1];if(a.type===r&&b.type===q){this.tokens.push(a),this.ast=this.ast.parent;break}this.subParse(a,R),b=this.tokens[this.tokens.length-1];if(m&&m.type===c||b&&b.type===w)this.ast=this.ast.parent;break;case j:this.tokens.push(a),this.ast=this.ast.beget(Q);break;case E:b=this.tokens[this.tokens.length-1],b&&(b.type===w||b.type===x||b.type===p||b.type===E||this.ast.parent&&this.ast.parent.mode===R)?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;default:this.ast.parent&&this.ast.parent.mode!==R?(this.ast=this.ast.parent,this.tokens.push(a)):this.ast.push(a)}}};var T=S.prototype;T.insertDebugVars=function(a){this.options.debug&&this.buffer.push(this.options.helpersName+".vl = "+a.line+", ",this.options.helpersName+".vc = "+a.chr+"; \n")},T.visitMarkupTok=function(a,b,c){this.insertDebugVars(a),this.buffer.push("MKP("+a.val.replace(this.reEscapedQuote,"\\\\$1").replace(this.reQuote,"\\$1").replace(this.reLineBreak,"\\n")+")MKP")},T.visitBlockTok=function(a,b,c){this.buffer.push(a.val)},T.visitExpressionTok=function(a,b,c,d){var e="",f="",g=b.parent&&b.parent.mode!==R;this.options.htmlEscape!==!1&&(g&&c===0&&d&&(e+=this.options.helpersName+".escape("),g&&c===b.length-1&&d&&(f+=").toHtmlString()")),g&&c===0&&(this.insertDebugVars(a),e="__vbuffer.push("+e),g&&c===b.length-1&&(f+="); \n"),this.buffer.push(e+a.val+f),g&&c===b.length-1&&this.insertDebugVars(a)},T.visitNode=function(a){var b,d=a.slice(0),f,g,h;a.mode===R&&a.parent&&a.parent.mode!==R&&(f=a.filter(S.findNonExp).length);for(g=0;g<d.length;g++){h=d[g];if(h.type&&h.type===c||h.type===e)continue;h.vquery?this.visitNode(h):a.mode===P?this.visitMarkupTok(h,a,g):a.mode===Q?this.visitBlockTok(h,a,g):a.mode===R&&this.visitExpressionTok(h,a,g,f>0?!1:!0)}},T.escapeForDebug=function(a){return a.replace(this.reLineBreak,"!LB!").replace(this.reQuote,"\\$1").replace(this.reEscapedQuote,"\\$1")},T.replaceDevTokens=function(a){return a.replace(this.reHelpersName,this.options.helpersName).replace(this.reModelName,this.options.modelName)},T.addHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = HELPERSNAME.buffer; \n"+"HELPERSNAME.options = __vopts; \n"+"MODELNAME = MODELNAME || {}; \n"+(b.useWith?"with( MODELNAME ){ \n":"");c=this.replaceDevTokens(c);return c+a},T.addHelperHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = this.buffer; \n"+"var MODELNAME = this.model; \n"+"var HELPERSNAME = this; \n";c=this.replaceDevTokens(c);return c+a},T.addFoot=function(a){var b=this.options,c=""+(b.simple?'return HELPERSNAME.buffer.join(""); \n':"(__vopts && __vopts.onRenderEnd && __vopts.onRenderEnd(null, HELPERSNAME)); \nreturn (__vopts && __vopts.asContext) \n ? HELPERSNAME \n : HELPERSNAME.toString(); \n")+(b.useWith?"} \n":"")+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},T.addHelperFoot=function(a){var b=this.options,c=""+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},T.generate=function(){var a=this.options;this.buffer.length=0,this.visitNode(this.ast);var c=this.buffer.join("").split(")MKPMKP(").join("").split("MKP(").join("__vbuffer.push('").split(")MKP").join("'); \n");a.asHelper?(c=this.addHelperHead(c),c=this.addHelperFoot(c)):(c=this.addHead(c),c=this.addFoot(c)),a.debugCompiler&&(console.log(c),console.log(a)),this.cmpFunc=b.link(c,a);return this.cmpFunc},S.noop=function(){},S.findNonExp=function(a){return a.vquery&&a.mode===R?a.filter(S.findNonExp).length>0:a.vquery&&a.mode!==R?!0:!1},a.config={useWith:!1,modelName:"model",helpersName:"html",htmlEscape:!0,debug:!0,debugParser:!1,debugCompiler:!1,simple:!1,favorText:!1,externs:["window","document"],saveTextTag:!1,saveAT:!1},a.compile=function(b,c){if(b===""||typeof b!="string")throw new Error("Empty or non-string cannot be compiled");var d,e,f=[],g,h,i,j;c=M.extend({},a.config,c||{}),d=new L(b);while(e=d.advance())f.push(e);f.reverse(),g=new N(f,c),g.parse(),h=new S(g.ast,b,c),i=h.generate();return i};var U=Array.prototype.slice,V=/vash\.helpers\.([^= ]+?)\s*=\s*function([^(]*?)\(([^)]*?)\)\s*{/,W=/\}$/,X=/^\/\/\s*@\s*batch\s*=\s*(.*?)$/,Y=function(a,b,c,d){var e=b.split(/[\n\r]/g),f={},g=[],h="";e.forEach(function(b,e){var g=a.exec(b),i=g?c.apply(g,g):null;i&&(h=i,f[h]=[]),(!i||d)&&b&&f[h].push(b)}),Object.keys(f).forEach(function(a){f[a]=f[a].join("\n")});return f},Z=function(a,c,d){var e=a==="helper"?V:X,f=Y(e,c,function(a,b){return b.replace(/^\s+|\s+$/,"")},a==="helper"?!0:!1);f&&(Object.keys(f).forEach(function(c){f[c]=a==="helper"?$(f[c],d):b.compile("@{"+f[c]+"}",d)}),f.toClientString=function(){return Object.keys(f).reduce(function(a,b){return b==="toClientString"?a:a+f[b].toClientString()+"\n"},"")});return f},$=function(a,c){c=c||{};var d=a.replace(/^[\s\n\r]+|[\s\n\r]+$/,"").match(V),e=d[3].split(",").map(function(a){return a.replace(" ","")}),f=d[1],g=a.replace(V,"").replace(W,"");g="@{"+g+"}",c.args=e,c.asHelper=f;return b.compile(g,c)};a.compileHelper=Z.bind(null,"helper"),a.compileBatch=a.batch=Z.bind(null,"batch"),a.VLexer=L,a.VParser=N,a.VCompiler=S,a.vQuery=M,function(){function j(a,b){typeof b=="function"&&(b={onRenderEnd:b}),a&&a.onRenderEnd&&(b=b||{},b.onRenderEnd||(b.onRenderEnd=a.onRenderEnd),delete a.onRenderEnd),b||(b={});return b}b=typeof b=="undefined"?{}:b,b.compile||(typeof define=="function"&&define.amd?define(function(){return b}):typeof module=="object"&&module.exports?module.exports=b:window.vash=b);var a=b.helpers,c=function(a){this.buffer=new g,this.model=a,this.options=null,this.vl=0,this.vc=0};b.helpers=a=c.prototype={constructor:c,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer._vo.join("")};var d=/[&<>"'`]/g,e=function(a){return f[a]},f={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};a.raw=function(a){var b=function(){return a};a=a!=null?a:"";return{toHtmlString:b,toString:b}},a.escape=function(a){var b=function(){return a};a=a!=null?a:"";if(typeof a.toHtmlString!="function"){a=a.toString().replace(d,e);return{toHtmlString:b,toString:b}}return a};var g=function(){this._vo=[]};g.prototype.mark=function(a){var b=new h(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},g.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},g.prototype.spliceMark=function(a,b,c){var d=a.findInBuffer();if(d>-1){a.destroy(),arguments[0]=d;return this._vo.splice.apply(this._vo,arguments)}return[]},g.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},g.prototype.push=function(a){return this._vo.push(a)},g.prototype.pushConcat=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a);return this.__vo},g.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.lastIndexOf=function(a){var b=this._vo.length;while(--b>=0)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},g.prototype.index=function(a){return this._vo[a]},g.prototype.flush=function(){return this.empty().join("")},g.prototype.toString=g.prototype.toHtmlString=function(){return this._vo.join("")};var h=b.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},i=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;h.uidLike=function(a){return(a||"").search(i)>-1},h.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},h.prototype.findInBuffer=function(){return this.destroyed?-1:this.markedIndex&&this.buffer.index(this.markedIndex)===this.uid?this.markedIndex:this.markedIndex=this.buffer.indexOf(this.uid)},a.constructor.reportError=function(a,b,c,d,e){e=e||"!LB!";var f=d.split(e),g=b===0&&c===0?f.length-1:3,h=Math.max(0,b-g),i=Math.min(f.length,b+g),j=f.slice(h,i).map(function(a,c,d){var e=c+h+1;return(e===b?" > ":" ")+(e<10?" ":"")+e+" | "+a}).join("\n");a.vashlineno=b,a.vashcharno=c,a.message="Problem while rendering template at line "+b+", character "+c+".\nOriginal message: "+a.message+"."+"\nContext: \n\n"+j+"\n\n";throw a},a.reportError=function(){this.constructor.reportError.apply(this,arguments)},b.link=function(d,e){var f,g;e.args||(e.args=[e.modelName,e.helpersName,"__vopts","vash"]);if(typeof d=="string"){f=d;try{g=e.args.slice(),g.push(d),d=Function.apply(null,g)}catch(h){a.reportError(h,0,0,f,/\n/)}}d.options={simple:e.simple,modelName:e.modelName,helpersName:e.helpersName};var i;e.asHelper?(d.options.args=e.args,d.options.asHelper=e.asHelper,i=function(){return d.apply(this,k.call(arguments))},a[e.asHelper]=i):i=function(a,f){if(e.simple){var g={buffer:[],escape:c.prototype.escape,raw:c.prototype.raw};return d(a,g,f,b)}f=j(a,f);return d(a,f&&f.context||new c(a),f,b)},i.toString=function(){return d.toString()},i._toString=function(){return Function.prototype.toString.call(i)},i.toClientString=function(){return"vash.link( "+d.toString()+", "+JSON.stringify(d.options)+" )"};return i};var k=Array.prototype.slice;b.lookup=function(a,c){var d=b.helpers.tplcache[a];if(!d)throw new Error("Could not find template: "+a);return c?d(c):d},b.install=function(a,c){var d=b.helpers.tplcache;if(typeof c=="string"){if(!b.compile)throw new Error("vash.install(path, [string]) is not available in the standalone runtime.");c=b.compile(c)}else if(typeof a=="object"){c=a,Object.keys(c).forEach(function(a){d[a]=c[a]});return d}return d[a]=c},b.uninstall=function(a){var c=b.helpers.tplcache,d=!1;if(typeof a=="string")return delete c[a];Object.keys(c).forEach(function(b){c[b]===a&&(d=delete c[b])});return d}}(),function(){var a=b.helpers;a.trim=function(a){return a.replace(/^\s*|\s*$/g,"")},a.config.highlighter=null,a.highlight=function(b,c){var d=this.buffer.mark();c();var e=this.buffer.fromMark(d);this.buffer.push("<pre><code>"),a.config.highlighter?this.buffer.push(a.config.highlighter(b,e.join("")).value):this.buffer.push(e),this.buffer.push("</code></pre>")}}(),function(){if(typeof window=="undefined")var a=require("fs"),c=require("path");var d=b.helpers;d.config.browser=!1,b.loadFile=function(e,f,g){f=M.extend({},b.config,f||{});var h=d.config.browser,i;!h&&f.settings&&f.settings.views&&(e=c.normalize(e),e.indexOf(c.normalize(f.settings.views))===-1&&(e=c.join(f.settings.views,e)),c.extname(e)||(e+="."+(f.settings["view engine"]||"vash")));try{i=f.cache||h?d.tplcache[e]||(d.tplcache[e]=b.compile(a.readFileSync(e,"utf8"))):b.compile(a.readFileSync(e,"utf8")),g&&g(null,i)}catch(j){g&&g(j,null)}},b.renderFile=function(a,c,d){b.loadFile(a,c,function(a,b){var e=c.onRenderEnd;d(a,!a&&b(c,function(a,b){b.finishLayout(),e&&e(a,b)}))})},d._ensureLayoutProps=function(){this.appends=this.appends||{},this.prepends=this.prepends||{},this.blocks=this.blocks||{},this.blockMarks=this.blockMarks||{}},d.finishLayout=function(){this._ensureLayoutProps();var a=this,b,c,d,e,f,g,h,i;for(b in this.blockMarks)c=this.blockMarks[b],e=this.prepends[b],d=this.blocks[b],f=this.appends[b],g=c.pop(),h=this.buffer.mark(),e&&e.forEach(function(b){a.buffer.pushConcat(b)}),block=d.pop(),block&&this.buffer.pushConcat(block),f&&f.forEach(function(b){a.buffer.pushConcat(b)}),i=this.buffer.fromMark(h),i.unshift(g,0),this.buffer.spliceMark.apply(this.buffer,i);for(b in this.blockMarks)this.blockMarks[b].forEach(function(a){a.destroy()});delete this.blockMarks,delete this.prepends,delete this.blocks,delete this.appends;return this.toString()},d.extend=function(a,c){var d=this,e=this.buffer,f=this.model,g;this._ensureLayoutProps(),b.loadFile(a,this.model,function(a,b){var e=d.buffer.mark();c(d.model);var f=d.buffer.fromMark(e);d.isExtending=!0,b(d.model,{context:d}),d.isExtending=!1}),this.model=f},d.include=function(a,c){var d=this,e=this.buffer,f=this.model;b.loadFile(a,this.model,function(a,b){b(c||d.model,{context:d})}),this.model=f},d.block=function(a,b){this._ensureLayoutProps();var c=this,d=this.blockMarks[a]||(this.blockMarks[a]=[]),e=this.blocks[a]||(this.blocks[a]=[]),f,g;b&&(f=this.buffer.mark(),b(this.model),g=this.buffer.fromMark(f),g.length&&!this.isExtending&&e.push(g),g.length&&this.isExtending&&e.unshift(g)),d.push(this.buffer.mark("block-"+a))},d._handlePrependAppend=function(a,b,c){this._ensureLayoutProps();var d=this.buffer.mark(),e,f=this[a],g=f[b]||(f[b]=[]);c(this.model),e=this.buffer.fromMark(d),g.push(e)},d.append=function(a,b){this._handlePrependAppend("appends",a,b)},d.prepend=function(a,b){this._handlePrependAppend("prepends",a,b)}}(),a.__express=a.renderFile;return a}({version:"0.7.6-2"}))
</script>
<!-- /VASH -->
<!--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>
window.sharedVariables = {
header: "Header",
header2: "Header2",
header3: "Header3",
header4: "Header4",
header5: "Header5",
header6: "Header6",
list: ['1000000000', '2', '3', '4', '5', '6', '7', '8', '9', '10']
};
//JsRender compiled template (no encoding)
window.jsRenderTemplate = $.templates("<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}}<li class='item'>{{:#data}}</li>{{/for}}</ul></div>");
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.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>");
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.kendoUIAlt = kendo.template($("#kendoUIextTemplate").html());
window.kendoUIAlt2 = kendo.template($("#kendoUIextTemplate").html(), {useWithBlock:false});
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.underscoreTemplateNoWith = _.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>", null, {variable: 'data'});
window.baseHtml = "<div><h1 class='header'></h1><h2 class='header2'></h2><h3 class='header3'></h3><h4 class='header4'></h4><h5 class='header5'></h5><h6 class='header6'></h6><ul class='list'><li class='item'></li></ul></div>";
window.doTtemplate = doT.template("<div><h1 class='header'>{{=it.header}}</h1><h2 class='header2'>{{=it.header2}}</h2><h3 class='header3'>{{=it.header3}}</h3><h4 class='header4'>{{=it.header4}}</h4><h5 class='header5'>{{=it.header5}}</h5><h6 class='header6'>{{=it.header6}}</h6><ul class='list'>{{for(var i = 0,l=it.list.length;i<l;i++) { }}<li class='item'>{{=it.list[i]}}</li>{{ } }}</ul></div>");
//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.dusttemplate = dust.compileFn("<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.jadeTemplate = jade.compile("div\n h1.header!= self.header\n h2.header2!= self.header2\n h3.header3!= self.header3\n h4.header4!= self.header4\n h5.header5!= self.header5\n h6.header6!= self.header6\n ul.list\n - each item in self.list\n li.item!= item", { compileDebug: false, self: true});
window.hoganTemplate = 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>");
window.juicerTemplate = "<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'>{@each data.list as it}<li class='item'>$${it}</li>{@/each}</ul></div>";
window.juicerTpl=juicer.compile(juicerTemplate,{cache:true,errorhandling:false,detection:false});
window.vashtemplate = vash.compile("<div><h1 class='header'>@model.header</h1><h2 class='header2'>@model.header2</h2><h3 class='header3'>@model.header3</h3><h4 class='header4'>@model.header4</h4><h5 class='header5'>@model.header5</h5><h6 class='header6'>@model.header6</h6><ul class='list'>@model.list.forEach(function(m) {<li class='item'>@m</li> })</ul></div>");
//window.hamlTemplate = haml.compileHaml({source:"%div\n %h1.header= header\n %h2.header2= header2\n %h3.header3= header3\n %h4.header4= header4\n %h5.header5= header5\n %h6.header6= header6\n %ul.list\n :each item in list\n %li.item= item"});
(function(){
this.templates || (this.templates = {});
this.templates["koffee"] = function anonymous(data) {
var a,div,em,h1,h2,h3,h4,h5,h6,head,header,i,li,p,s,th,u,ul;a = function(){return __ck.tag('a', arguments);};div = function(){return __ck.tag('div', arguments);};em = function(){return __ck.tag('em', arguments);};h1 = function(){return __ck.tag('h1', arguments);};h2 = function(){return __ck.tag('h2', arguments);};h3 = function(){return __ck.tag('h3', arguments);};h4 = function(){return __ck.tag('h4', arguments);};h5 = function(){return __ck.tag('h5', arguments);};h6 = function(){return __ck.tag('h6', arguments);};head = function(){return __ck.tag('head', arguments);};header = function(){return __ck.tag('header', arguments);};i = function(){return __ck.tag('i', arguments);};li = function(){return __ck.tag('li', arguments);};p = function(){return __ck.tag('p', arguments);};s = function(){return __ck.tag('s', arguments);};th = function(){return __ck.tag('th', arguments);};u = function(){return __ck.tag('u', arguments);};ul = function(){return __ck.tag('ul', arguments);};var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };
var coffeescript, comment, doctype, h, ie, tag, text, yield, __ck, _ref, _ref2;
if (data == null) {
data = {};
}
if ((_ref = data.format) == null) {
data.format = false;
}
if ((_ref2 = data.autoescape) == null) {
data.autoescape = false;
}
__ck = {
buffer: [],
esc: function(txt) {
if (data.autoescape) {
return h(txt);
} else {
return String(txt);
}
},
tabs: 0,
repeat: function(string, count) {
return Array(count + 1).join(string);
},
indent: function() {
if (data.format) {
return text(this.repeat(' ', this.tabs));
}
},
tag: function(name, args) {
var combo, i, _i, _len;
combo = [name];
for (_i = 0, _len = args.length; _i < _len; _i++) {
i = args[_i];
combo.push(i);
}
return tag.apply(data, combo);
},
render_idclass: function(str) {
var c, classes, i, id, _i, _j, _len, _len2, _ref3;
classes = [];
_ref3 = str.split('.');
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
i = _ref3[_i];
if (__indexOf.call(i, '#') >= 0) {
id = i.replace('#', '');
} else {
if (i !== '') {
classes.push(i);
}
}
}
if (id) {
text(" id=\"" + id + "\"");
}
if (classes.length > 0) {
text(" class=\"");
for (_j = 0, _len2 = classes.length; _j < _len2; _j++) {
c = classes[_j];
if (c !== classes[0]) {
text(' ');
}
text(c);
}
return text('"');
}
},
render_attrs: function(obj, prefix) {
var k, v, _results;
if (prefix == null) {
prefix = '';
}
_results = [];
for (k in obj) {
v = obj[k];
if (typeof v === 'boolean' && v) {
v = k;
}
if (typeof v === 'function') {
v = "(" + v + ").call(this);";
}
_results.push(typeof v === 'object' && !(v instanceof Array) ? this.render_attrs(v, prefix + k + '-') : v ? text(" " + (prefix + k) + "=\"" + (this.esc(v)) + "\"") : void 0);
}
return _results;
},
render_contents: function(contents) {
var result;
switch (typeof contents) {
case 'string':
case 'number':
case 'boolean':
return text(this.esc(contents));
case 'function':
if (data.format) {
text('\n');
}
this.tabs++;
result = contents.call(data);
if (typeof result === 'string') {
this.indent();
text(this.esc(result));
if (data.format) {
text('\n');
}
}
this.tabs--;
return this.indent();
}
},
render_tag: function(name, idclass, attrs, contents) {
this.indent();
text("<" + name);
if (idclass) {
this.render_idclass(idclass);
}
if (attrs) {
this.render_attrs(attrs);
}
if (__indexOf.call(this.self_closing, name) >= 0) {
text(' />');
if (data.format) {
text('\n');
}
} else {
text('>');
this.render_contents(contents);
text("</" + name + ">");
if (data.format) {
text('\n');
}
}
return null;
}
};
tag = function() {
var a, args, attrs, contents, idclass, name, _i, _len;
name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
a = args[_i];
switch (typeof a) {
case 'function':
contents = a;
break;
case 'object':
attrs = a;
break;
case 'number':
case 'boolean':
contents = a;
break;
case 'string':
if (args.length === 1) {
contents = a;
} else {
if (a === args[0]) {
idclass = a;
} else {
contents = a;
}
}
}
}
return __ck.render_tag(name, idclass, attrs, contents);
};
yield = function(f) {
var old_buffer, temp_buffer;
temp_buffer = [];
old_buffer = __ck.buffer;
__ck.buffer = temp_buffer;
f();
__ck.buffer = old_buffer;
return temp_buffer.join('');
};
h = function(txt) {
return String(txt).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
};
doctype = function(type) {
if (type == null) {
type = 'default';
}
text(__ck.doctypes[type]);
if (data.format) {
return text('\n');
}
};
text = function(txt) {
__ck.buffer.push(String(txt));
return null;
};
comment = function(cmt) {
text("<!--" + cmt + "-->");
if (data.format) {
return text('\n');
}
};
coffeescript = function(param) {
switch (typeof param) {
case 'function':
return script("" + __ck.coffeescript_helpers + "(" + param + ").call(this);");
case 'string':
return script({
type: 'text/coffeescript'
}, function() {
return param;
});
case 'object':
param.type = 'text/coffeescript';
return script(param);
}
};
ie = function(condition, contents) {
__ck.indent();
text("<!--[if " + condition + "]>");
__ck.render_contents(contents);
text("<![endif]-->");
if (data.format) {
return text('\n');
}
};
__ck.doctypes = {"5":"<!DOCTYPE html>","default":"<!DOCTYPE html>","xml":"<?xml version=\"1.0\" encoding=\"utf-8\" ?>","transitional":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">","strict":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">","frameset":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">","1.1":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">","basic":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">","mobile":"<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">","ce":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"ce-html-1.0-transitional.dtd\">"};__ck.coffeescript_helpers = "var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };";__ck.self_closing = ["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","basefont","frame"];(function(){
div(function() {
h1('.header', function() {
return this.header;
});
h2('.header2', function() {
return this.header2;
});
h3('.header3', function() {
return this.header3;
});
h4('.header4', function() {
return this.header4;
});
h5('.header5', function() {
return this.header5;
});
h6('.header6', function() {
return this.header6;
});
return ul('.list', function() {
var item, _i, _len, _ref, _results;
_ref = this.list;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push(li('.item', function() {
return item;
}));
}
return _results;
});
});
}).call(data);return __ck.buffer.join('');
};
}).call(this);
window.coffeekupTemplate = templates.koffee;
</script>
<div id="template" style="display:none"></div>
Ready to run.
Test | Ops/sec | |
---|---|---|
doT.js |
| ready |
Handlebars.js |
| ready |
Underscore.js Template |
| ready |
Resig Micro Templates (modified) |
| ready |
Resig Micro Templates (No "with" block) |
| ready |
Underscore.js Template (No "with") |
| ready |
Hogan.js |
| ready |
JsRender |
| ready |
Mustache.js Template |
| ready |
Jade Template (No "with") |
| ready |
CoffeeKup compiled template |
| ready |
Dust JS template |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.