File Coverage

lib/Amon2/Setup/Asset/MicroTemplateJS.pm
Criterion Covered Total %
statement 7 8 87.5
branch n/a
condition n/a
subroutine 3 4 75.0
pod 0 2 0.0
total 10 14 71.4


line stmt bran cond sub pod time code
1             # This file is generated by author/assets.pl. Do not edit manually.
2             use strict;
3 1     1   544 use warnings;
  1         3  
  1         36  
4 1     1   5  
  1         3  
  1         95  
5             <<',,,';
6             <script src="<: uri_for('/static/js/micro_template.js') :>"></script>
7 1     1 0 31 ,,,
8             }
9              
10             return {
11             'js/micro_template.js' => '// Simple JavaScript Templating
12             // John Resig - http://ejohn.org/ - MIT Licensed
13             (function(){
14 0     0 0   var cache = {};
15             this.tmpl = function tmpl(str, data){
16             // Figure out if we\'re getting a template, or if we need to
17             // load the template - and be sure to cache the result.
18             var fn = !/\\W/.test(str) ?
19             cache[str] = cache[str] ||
20             tmpl(document.getElementById(str).innerHTML) :
21              
22             // Generate a reusable function that will serve as a template
23             // generator (and which will be cached).
24             new Function("obj",
25             "var p=[];" +
26              
27             // Introduce the data as local variables using with(){}
28             "with(obj){p.push(\'" +
29              
30             // Convert the template into pure JavaScript
31             str
32             .replace(/[\\r\\t\\n]/g, " ")
33             .split("<%").join("\\t")
34             .replace(/(^|%>)[^\\t]*?(\\t|$)/g, function(){return arguments[0].split("\'").join("\\\\\'");})
35             .replace(/\\t==(.*?)%>/g,"\',$1,\'")
36             .replace(/\\t=(.*?)%>/g, "\',(($1)+\'\').replace(/&/g,\'&amp;\').replace(/</g,\'&lt;\').replace(/>/g,\'&gt;\').replace(/\\"/g,\'&quot;\').replace(/\\\'/g,\'&#39;\'),\'")
37             .split("\\t").join("\');")
38             .split("%>").join("p.push(\'")
39             + "\');}return p.join(\'\');");
40              
41             // Provide some basic currying to the user
42             return data ? fn( data ) : fn;
43             };
44             })();
45             '
46             }
47             ;
48             }
49              
50             1;