vendor: 5,249 bytes, lines 1-144
1// doT.js 2// 2011-2014, Laura Doktorova, https://github.com/olado/doT 3// Licensed under the MIT license. 4 5(function () { 6 "use strict"; 7 8 var doT = { 9 name: "doT", 10 version: "1.1.1", 11 templateSettings: { 12 evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g, 13 interpolate: /\{\{=([\s\S]+?)\}\}/g, 14 encode: /\{\{!([\s\S]+?)\}\}/g, 15 use: /\{\{#([\s\S]+?)\}\}/g, 16 useParams: /(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g, 17 define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g, 18 defineParams:/^\s*([\w$]+):([\s\S]+)/, 19 conditional: /\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g, 20 iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g, 21 varname: "it", 22 strip: true, 23 append: true, 24 selfcontained: false, 25 doNotSkipEncoded: false 26 }, 27 template: undefined, //fn, compile template 28 compile: undefined, //fn, for express 29 log: true 30 }, _globals; 31 32 doT.encodeHTMLSource = function(doNotSkipEncoded) { 33 var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/" }, 34 matchHTML = doNotSkipEncoded ? /[&<>"'\/]/g : /&(?!#?\w+;)|<|>|"|'|\//g; 35 return function(code) { 36 return code ? code.toString().replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : ""; 37 }; 38 }; 39 40 _globals = (function(){ return this || (0,eval)("this"); }()); 41 42 /* istanbul ignore else */ 43 if (typeof module !== "undefined" && module.exports) { 44 module.exports = doT; 45 } else if (typeof define === "function" && define.amd) { 46 define(function(){return doT;}); 47 } else { 48 _globals.doT = doT; 49 } 50 51 var startend = { 52 append: { start: "'+(", end: ")+'", startencode: "'+encodeHTML(" }, 53 split: { start: "';out+=(", end: ");out+='", startencode: "';out+=encodeHTML(" } 54 }, skip = /$^/; 55 56 function resolveDefs(c, block, def) { 57 return ((typeof block === "string") ? block : block.toString()) 58 .replace(c.define || skip, function(m, code, assign, value) { 59 if (code.indexOf("def.") === 0) { 60 code = code.substring(4); 61 } 62 if (!(code in def)) { 63 if (assign === ":") { 64 if (c.defineParams) value.replace(c.defineParams, function(m, param, v) { 65 def[code] = {arg: param, text: v}; 66 }); 67 if (!(code in def)) def[code]= value; 68 } else { 69 new Function("def", "def['"+code+"']=" + value)(def); 70 } 71 } 72 return ""; 73 }) 74 .replace(c.use || skip, function(m, code) { 75 if (c.useParams) code = code.replace(c.useParams, function(m, s, d, param) { 76 if (def[d] && def[d].arg && param) { 77 var rw = (d+":"+param).replace(/'|\\/g, "_"); 78 def.__exp = def.__exp || {}; 79 def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2"); 80 return s + "def.__exp['"+rw+"']"; 81 } 82 }); 83 var v = new Function("def", "return " + code)(def); 84 return v ? resolveDefs(c, v, def) : v; 85 }); 86 } 87 88 function unescape(code) { 89 return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " "); 90 } 91 92 doT.template = function(tmpl, c, def) { 93 c = c || doT.templateSettings; 94 var cse = c.append ? startend.append : startend.split, needhtmlencode, sid = 0, indv, 95 str = (c.use || c.define) ? resolveDefs(c, tmpl, def || {}) : tmpl; 96 97 str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ") 98 .replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""): str) 99 .replace(/'|\\/g, "\\$&") 100 .replace(c.interpolate || skip, function(m, code) { 101 return cse.start + unescape(code) + cse.end; 102 }) 103 .replace(c.encode || skip, function(m, code) { 104 needhtmlencode = true; 105 return cse.startencode + unescape(code) + cse.end; 106 }) 107 .replace(c.conditional || skip, function(m, elsecase, code) { 108 return elsecase ? 109 (code ? "';}else if(" + unescape(code) + "){out+='" : "';}else{out+='") : 110 (code ? "';if(" + unescape(code) + "){out+='" : "';}out+='"); 111 }) 112 .replace(c.iterate || skip, function(m, iterate, vname, iname) { 113 if (!iterate) return "';} } out+='"; 114 sid+=1; indv=iname || "i"+sid; iterate=unescape(iterate); 115 return "';var arr"+sid+"="+iterate+";if(arr"+sid+"){var "+vname+","+indv+"=-1,l"+sid+"=arr"+sid+".length-1;while("+indv+"<l"+sid+"){" 116 +vname+"=arr"+sid+"["+indv+"+=1];out+='"; 117 }) 118 .replace(c.evaluate || skip, function(m, code) { 119 return "';" + unescape(code) + "out+='"; 120 }) 121 + "';return out;") 122 .replace(/\n/g, "\\n").replace(/\t/g, '\\t').replace(/\r/g, "\\r") 123 .replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, ""); 124 //.replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); 125 126 if (needhtmlencode) { 127 if (!c.selfcontained && _globals && !_globals._encodeHTML) _globals._encodeHTML = doT.encodeHTMLSource(c.doNotSkipEncoded); 128 str = "var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : (" 129 + doT.encodeHTMLSource.toString() + "(" + (c.doNotSkipEncoded || '') + "));" 130 + str; 131 } 132 try { 133 return new Function(c.varname, str); 134 } catch (e) { 135 /* istanbul ignore else */ 136 if (typeof console !== "undefined") console.log("Could not create a template function: " + str); 137 throw e; 138 } 139 }; 140 141 doT.compile = function(tmpl, def) { 142 return doT.template(tmpl, null, def); 143 }; 144}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.