1/** 2 * Created by xclassicx on 08.02.2016. 3 * 4 * @link https://johnresig.com/blog/javascript-micro-templating/ 5 */ 6// Simple JavaScript Templating 7// John Resig - http://ejohn.org/ - MIT Licensed 8(function(){ 9 var cache = {}; 10 11 this.tmpl = function tmpl(str, data){ 12 // Figure out if we're getting a template, or if we need to 13 // load the template - and be sure to cache the result. 14 var fn = !/\W/.test(str) ? 15 cache[str] = cache[str] || 16 tmpl(document.getElementById(str).innerHTML) : 17 18 // Generate a reusable function that will serve as a template 19 // generator (and which will be cached). 20 (function() { 21 var src = 22 "var p=[],print=function(){p.push.apply(p,arguments);};" + 23 "with(obj){p.push('" + 24 str 25 .replace(/[\r\t\n]/g, " ") 26 .split("<%").join("\t") 27 .replace(/((^|%>)[^\t]*)'/g, "$1\r") 28 .replace(/\t=(.*?)%>/g, "',$1,'") 29 .split("\t").join("');") 30 .split("%>").join("p.push('") 31 .split("\r").join("\\'") 32 + "');}return p.join('');"; 33 try { 34 return new Function("obj", src); 35 } catch (e) { 36 console.error("[tmpl] Failed to compile template. Error:", e.message); 37 console.error("[tmpl] Template id/str:", str.length < 80 ? str : str.slice(0, 80) + "â¦"); 38 console.error("[tmpl] Generated source:\n" + src); 39 throw e; 40 } 41 })() 42 43 // Provide some basic currying to the user 44 return data ? fn( data ) : fn; 45 }; 46})();
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.