["// Simple JavaScript Templating",
"\n",
"// John Resig - http://ejohn.org/ - MIT Licensed",
"\n",
"(",
"function",
"(",
")",
"{",
"\n",
" ",
" ",
"var",
" ",
"cache",
" ",
"=",
" ",
"{",
"}",
";",
"\n",
"\n",
" ",
" ",
"this",
".",
"tmpl",
" ",
"=",
" ",
"function",
" ",
"tmpl",
"(",
"str",
",",
" ",
"data",
")",
"{",
"\n",
" ",
" ",
" ",
" ",
"// Figure out if we're getting a template, or if we need to",
"\n",
" ",
" ",
" ",
" ",
"// load the template - and be sure to cache the result.",
"\n",
" ",
" ",
" ",
" ",
"var",
" ",
"fn",
" ",
"=",
" ",
"!",
"/\\W/",
".",
"test",
"(",
"str",
")",
" ",
"?",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
"cache",
"[",
"str",
"]",
" ",
"=",
" ",
"cache",
"[",
"str",
"]",
" ",
"||",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"tmpl",
"(",
"document",
".",
"getElementById",
"(",
"str",
")",
".",
"innerHTML",
")",
" ",
":",
"\n",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
"// Generate a reusable function that will serve as a template",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
"// generator (and which will be cached).",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
"new",
" ",
"Function",
"(",
"\"obj\"",
",",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"\"var p=[],print=function(){p.push.apply(p,arguments);};\"",
" ",
"+",
"\n",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"// Introduce the data as local variables using with(){}",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"\"with(obj){p.push('\"",
" ",
"+",
"\n",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"// Convert the template into pure JavaScript",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"str",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"replace",
"(",
"/[\\r\\t\\n]/g",
",",
" ",
"\" \"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"split",
"(",
"\"<%\"",
")",
".",
"join",
"(",
"\"\\t\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"replace",
"(",
"/((^|%>)[^\\t]*)'/g",
",",
" ",
"\"$1\\r\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"replace",
"(",
"/\\t=(.*?)%>/g",
",",
" ",
"\"',$1,'\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"split",
"(",
"\"\\t\"",
")",
".",
"join",
"(",
"\"');\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"split",
"(",
"\"%>\"",
")",
".",
"join",
"(",
"\"p.push('\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
".",
"split",
"(",
"\"\\r\"",
")",
".",
"join",
"(",
"\"\\\\'\"",
")",
"\n",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"+",
" ",
"\"');}return p.join('');\"",
")",
";",
"\n",
"\n",
" ",
" ",
" ",
" ",
"// Provide some basic currying to the user",
"\n",
" ",
" ",
" ",
" ",
"return",
" ",
"data",
" ",
"?",
" ",
"fn",
"(",
" ",
"data",
" ",
")",
" ",
":",
" ",
"fn",
";",
"\n",
" ",
" ",
"}",
";",
"\n",
"}",
")",
"(",
")",
";"]