Comparing version 0.1.5 to 0.1.6
@@ -7,4 +7,4 @@ /**! | ||
* @author gnosaij | http://jias.github.io | http://www.joy-studio.com | ||
* @version 0.1.5 | ||
* @update 2014-05-14 | ||
* @version 0.1.6 | ||
* @update 2014-05-19 | ||
* @link http://www.joy-studio.com/javascript/my-eoraptorjs-template-engine-in-javascript.html | ||
@@ -15,6 +15,6 @@ */ | ||
var eoraptor = { | ||
name: 'eoraptor.js', | ||
version: '0.1.5', | ||
name: 'eoraptorjs', | ||
version: '0.1.6', | ||
compile: compile, | ||
setDelimiter: setDelimiter, | ||
// setDelimiter: setDelimiter, | ||
escape: escaper, | ||
@@ -92,3 +92,3 @@ extract: extract, | ||
var codePrefix = 'var __=eoraptor._, e_=__.e, v_=__.v;\n'; | ||
var codePrefix = 'var ns=eoraptor, __=ns._, e_=__.e, v_=__.v;\n'; | ||
@@ -305,4 +305,8 @@ // to compile a template string to callable render | ||
// `=` output html-escaped value | ||
// str = foo >> d_.foo | ||
// str = ["f-o"] >> d_["f-o"] | ||
// str code | ||
// ———————————————————— | ||
// foo d_.foo | ||
// ["f-o"] d_["f-o"] | ||
// &foo foo | ||
// &["f-o"] window["f-o"] !!!TODO!!! | ||
case 1: | ||
@@ -356,5 +360,6 @@ str = joiner(str); | ||
case 9: | ||
code = str.replace(/^(\w+)\s(.+)$/, function (all, name, data) { | ||
code = str.replace(/^(\w+)(?:\s(.+))?$/, function (all, name, dataKey) { | ||
name = name.indexOf('-') > -1 ? '["'+name+'"]' : DOT+name; | ||
return 'r_.push(eoraptor'+name+'.render('+data+'));\n'; | ||
dataKey = dataKey ? joiner(dataKey) : 'd_'; | ||
return 'r_.push(ns'+name+'('+dataKey+'));\n'; | ||
}); | ||
@@ -361,0 +366,0 @@ break; |
@@ -1,2 +0,2 @@ | ||
/*! eoraptorjs v0.1.5 2014-05-14 gnosaij http://jias.github.io/eoraptor.js/ */ | ||
!function(a){function b(a,b){var e,f;if(a=a||r,b=b||{},e=b.id||a,f=q[e])return f;var g=b.oTag||u,h=b.cTag||v,i=c(d(a,g,h));return f=function(b){var c;try{c=new Function("data",D+i)(b)}catch(d){console.error('"'+d.message+'" from data and tpl below:'),console.log(b),console.log(a)}return c},f.render=f,f.source="function (data) {\n"+i+"\n}",q[e]=f}function c(a){var b,c,d,e=[],f=["var d_=data, r_=[];\n"];for(b=0,c=a.length;c>b;b++)switch(d=a[b],d.type){case void 0:e.push(d.str);break;case-1:e.length&&f.push(i(e.join(""))),e=[];break;case 1:f.push(j(e.join(""),d.sign)),e=[]}return e.length&&f.push(i(e.join(""))),f.push('return r_.join("");'),f.join("")}function d(a,b,c){var d,i,j,k,l,m=b.charAt(0),n=c.charAt(0),o=[],p={lastOTag:null,lastOSB:null},q=0,r=a.length;for(q=0;r>q;q++)d=a.charAt(q),d===m&&(i=e(a,b,q))?(p.lastOTag=i,o.push(i),q+=i.jump):p.lastOTag&&d===n&&(j=f(a,c,q))?(j.sign=p.lastOTag.sign,o.push(j),p.lastOTag.type=-1,p.lastOTag=null,q+=j.jump):d===w&&(k=g(a,q))?(p.lastOSB=k,o.push(k),q+=k.jump):p.lastOSB&&d===p.lastOSB.quote&&(l=h(a,q,p.lastOSB.quote))?(o.push(l),p.lastOSB=null,q+=l.jump):"\\"===d?(o.push({index:q,str:"\\"+a.charAt(q+1)}),q++):o.push({index:q,str:d});return o}function e(a,b,c){var d=b.length,e=a.substr(c,d),f=a.charAt(c+d);return b===e&&f&&A.indexOf(f)>-1?{str:e+f,index:c,sign:B[a.charAt(c+d)],jump:d}:void 0}function f(a,b,c){var d=b.length,e=a.substr(c,d);return b===e?{str:e,index:c,type:1,jump:d-1}:void 0}function g(a,b){var c=a.charAt(b+1);return c===z||c===y?{str:w+c,index:b,quote:c,jump:1}:void 0}function h(a,b,c){return a.charAt(b+1)===x?{str:c+x,index:b,quote:c,jump:1}:void 0}function i(a){return'r_.push("'+a.replace(/"/g,'\\"')+'");\n'}function j(a,b){a=C(a);var c="";switch(b){case 1:a=k(a),c="r_.push(e_(v_("+a+", d_)));\n";break;case 2:a=k(a),c="r_.push(v_("+a+", d_));\n";break;case 3:c="}\n";break;case 4:c=a.replace(E,function(a,b,c,d){return b=k(b),d=d||"k_","var "+d+", l_="+b+".length, "+c+";\nfor("+d+"=0; "+d+"<l_; "+d+"++){\n"+c+" = "+b+"["+d+"];\n"});break;case 5:c=a.replace(E,function(a,b,c,d){return b=k(b),d=d||"k_","var "+d+", "+c+";\nfor("+d+" in "+b+"){\nif(!"+b+".hasOwnProperty("+d+")) return;\n"+c+" = "+b+"["+d+"];\n"});break;case 6:c="if("+k(a)+"){";break;case 7:c="if(!"+k(a)+"){";break;case 8:c=a.length?"}else if("+k(a)+"){":"}else{";break;case 9:c=a.replace(/^(\w+)\s(.+)$/,function(a,b,c){return b=b.indexOf("-")>-1?'["'+b+'"]':s+b,"r_.push(eoraptor"+b+".render("+c+"));\n"})}return c}function k(a){var b;return b="&"===a.charAt(0)?a.substr(1):t+("["!==a.charAt(0)?s:r)+a}function l(a,b){a=a||"{{",b=b||"}}"}function m(a){return G[a]}function n(a){return null==a?r:r+String(a).replace(F,m)}function o(){for(var a,c=document.getElementsByTagName("script"),d=0,e=c.length;e>d;d++)a=c[d],!a.getAttribute("compiled")&&a.id&&a.innerHTML&&"text/x-eoraptor"===a.type&&(b(a.id,C(a.innerHTML)),a.setAttribute("compiled","1"))}function p(a,b){return typeof a===H?a.apply(b,[b]):a||r}var q={name:"eoraptor.js",version:"0.1.5",compile:b,setDelimiter:l,escape:n,extract:o,debug:!1,_:{e:n,v:p}},r="",s=".",t="d_",u="{{",v="}}",w="[",x="]",y="'",z='"',A="=-/^#?:!>",B={"=":1,"-":2,"/":3,"^":4,"#":5,"?":6,"!":7,":":8,">":9},C=("object"==typeof process&&"object"==typeof process.versions,r.trim?function(a){return a.trim()}:function(a){return a.replace(/^\s+/,r).replace(/\s+$/,r)}),D="var __=eoraptor._, e_=__.e, v_=__.v;\n",E=/^(.+?)\s(\w+)\s?(\w+)?.*$/,F=/[&<>"']/g,G={"&":"&","<":"<",">":">",'"':""","'":"'"},H="function";"undefined"!=typeof module&&module.exports?module.exports=q:"function"==typeof define&&define.amd?define("eoraptor",[],function(){return q}):a.eoraptor=q}(this); | ||
/*! eoraptorjs v0.1.6 2014-05-19 gnosaij http://jias.github.io/eoraptor.js/ */ | ||
!function(a){function b(a,b){var e,f;if(a=a||q,b=b||{},e=b.id||a,f=p[e])return f;var g=b.oTag||t,h=b.cTag||u,i=c(d(a,g,h));return f=function(b){var c;try{c=new Function("data",C+i)(b)}catch(d){console.error('"'+d.message+'" from data and tpl below:'),console.log(b),console.log(a)}return c},f.render=f,f.source="function (data) {\n"+i+"\n}",p[e]=f}function c(a){var b,c,d,e=[],f=["var d_=data, r_=[];\n"];for(b=0,c=a.length;c>b;b++)switch(d=a[b],d.type){case void 0:e.push(d.str);break;case-1:e.length&&f.push(i(e.join(""))),e=[];break;case 1:f.push(j(e.join(""),d.sign)),e=[]}return e.length&&f.push(i(e.join(""))),f.push('return r_.join("");'),f.join("")}function d(a,b,c){var d,i,j,k,l,m=b.charAt(0),n=c.charAt(0),o=[],p={lastOTag:null,lastOSB:null},q=0,r=a.length;for(q=0;r>q;q++)d=a.charAt(q),d===m&&(i=e(a,b,q))?(p.lastOTag=i,o.push(i),q+=i.jump):p.lastOTag&&d===n&&(j=f(a,c,q))?(j.sign=p.lastOTag.sign,o.push(j),p.lastOTag.type=-1,p.lastOTag=null,q+=j.jump):d===v&&(k=g(a,q))?(p.lastOSB=k,o.push(k),q+=k.jump):p.lastOSB&&d===p.lastOSB.quote&&(l=h(a,q,p.lastOSB.quote))?(o.push(l),p.lastOSB=null,q+=l.jump):"\\"===d?(o.push({index:q,str:"\\"+a.charAt(q+1)}),q++):o.push({index:q,str:d});return o}function e(a,b,c){var d=b.length,e=a.substr(c,d),f=a.charAt(c+d);return b===e&&f&&z.indexOf(f)>-1?{str:e+f,index:c,sign:A[a.charAt(c+d)],jump:d}:void 0}function f(a,b,c){var d=b.length,e=a.substr(c,d);return b===e?{str:e,index:c,type:1,jump:d-1}:void 0}function g(a,b){var c=a.charAt(b+1);return c===y||c===x?{str:v+c,index:b,quote:c,jump:1}:void 0}function h(a,b,c){return a.charAt(b+1)===w?{str:c+w,index:b,quote:c,jump:1}:void 0}function i(a){return'r_.push("'+a.replace(/"/g,'\\"')+'");\n'}function j(a,b){a=B(a);var c="";switch(b){case 1:a=k(a),c="r_.push(e_(v_("+a+", d_)));\n";break;case 2:a=k(a),c="r_.push(v_("+a+", d_));\n";break;case 3:c="}\n";break;case 4:c=a.replace(D,function(a,b,c,d){return b=k(b),d=d||"k_","var "+d+", l_="+b+".length, "+c+";\nfor("+d+"=0; "+d+"<l_; "+d+"++){\n"+c+" = "+b+"["+d+"];\n"});break;case 5:c=a.replace(D,function(a,b,c,d){return b=k(b),d=d||"k_","var "+d+", "+c+";\nfor("+d+" in "+b+"){\nif(!"+b+".hasOwnProperty("+d+")) return;\n"+c+" = "+b+"["+d+"];\n"});break;case 6:c="if("+k(a)+"){";break;case 7:c="if(!"+k(a)+"){";break;case 8:c=a.length?"}else if("+k(a)+"){":"}else{";break;case 9:c=a.replace(/^(\w+)(?:\s(.+))?$/,function(a,b,c){return b=b.indexOf("-")>-1?'["'+b+'"]':r+b,c=c?k(c):"d_","r_.push(ns"+b+"("+c+"));\n"})}return c}function k(a){var b;return b="&"===a.charAt(0)?a.substr(1):s+("["!==a.charAt(0)?r:q)+a}function l(a){return F[a]}function m(a){return null==a?q:q+String(a).replace(E,l)}function n(){for(var a,c=document.getElementsByTagName("script"),d=0,e=c.length;e>d;d++)a=c[d],!a.getAttribute("compiled")&&a.id&&a.innerHTML&&"text/x-eoraptor"===a.type&&(b(a.id,B(a.innerHTML)),a.setAttribute("compiled","1"))}function o(a,b){return typeof a===G?a.apply(b,[b]):a||q}var p={name:"eoraptorjs",version:"0.1.6",compile:b,escape:m,extract:n,debug:!1,_:{e:m,v:o}},q="",r=".",s="d_",t="{{",u="}}",v="[",w="]",x="'",y='"',z="=-/^#?:!>",A={"=":1,"-":2,"/":3,"^":4,"#":5,"?":6,"!":7,":":8,">":9},B=("object"==typeof process&&"object"==typeof process.versions,q.trim?function(a){return a.trim()}:function(a){return a.replace(/^\s+/,q).replace(/\s+$/,q)}),C="var ns=eoraptor, __=ns._, e_=__.e, v_=__.v;\n",D=/^(.+?)\s(\w+)\s?(\w+)?.*$/,E=/[&<>"']/g,F={"&":"&","<":"<",">":">",'"':""","'":"'"},G="function";"undefined"!=typeof module&&module.exports?module.exports=p:"function"==typeof define&&define.amd?define("eoraptor",[],function(){return p}):a.eoraptor=p}(this); |
@@ -45,2 +45,14 @@ module.exports = function(grunt) { | ||
} | ||
}, | ||
eoraptor_jst: { | ||
cmd: { | ||
options: { | ||
namespace: 'tpl', | ||
module: false, | ||
ext: 'tpl.html' | ||
}, | ||
files: { | ||
'tpl/tpl.js': ['tpl/*.tpl.html'] | ||
}, | ||
} | ||
} | ||
@@ -52,5 +64,7 @@ }); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('eoraptor-jst'); | ||
grunt.registerTask('default', ['replace','uglify']); | ||
grunt.registerTask('tpl', ['eoraptor_jst']); | ||
}; |
{ | ||
"family": "gnosaij", | ||
"name": "eoraptorjs", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A mini expression javascript template engine without any dependence. Compatible with client-side and server-side.", | ||
@@ -6,0 +6,0 @@ "homepage": "http://jias.github.io/eoraptor.js/", |
@@ -14,6 +14,6 @@ /**! | ||
var eoraptor = { | ||
name: 'eoraptor.js', | ||
name: 'eoraptorjs', | ||
version: '#VERSION#', | ||
compile: compile, | ||
setDelimiter: setDelimiter, | ||
// setDelimiter: setDelimiter, | ||
escape: escaper, | ||
@@ -91,3 +91,3 @@ extract: extract, | ||
var codePrefix = 'var __=eoraptor._, e_=__.e, v_=__.v;\n'; | ||
var codePrefix = 'var ns=eoraptor, __=ns._, e_=__.e, v_=__.v;\n'; | ||
@@ -304,4 +304,8 @@ // to compile a template string to callable render | ||
// `=` output html-escaped value | ||
// str = foo >> d_.foo | ||
// str = ["f-o"] >> d_["f-o"] | ||
// str code | ||
// ———————————————————— | ||
// foo d_.foo | ||
// ["f-o"] d_["f-o"] | ||
// &foo foo | ||
// &["f-o"] window["f-o"] !!!TODO!!! | ||
case 1: | ||
@@ -355,5 +359,6 @@ str = joiner(str); | ||
case 9: | ||
code = str.replace(/^(\w+)\s(.+)$/, function (all, name, data) { | ||
code = str.replace(/^(\w+)(?:\s(.+))?$/, function (all, name, dataKey) { | ||
name = name.indexOf('-') > -1 ? '["'+name+'"]' : DOT+name; | ||
return 'r_.push(eoraptor'+name+'.render('+data+'));\n'; | ||
dataKey = dataKey ? joiner(dataKey) : 'd_'; | ||
return 'r_.push(ns'+name+'('+dataKey+'));\n'; | ||
}); | ||
@@ -360,0 +365,0 @@ break; |
183
test/test.js
function xit () {} | ||
function xdescribe() {} | ||
describe('usage test', function () { | ||
var ec = eoraptor.compile; | ||
var ec = eoraptor.compile; | ||
describe('no expression', function () { | ||
it('a', function(){ | ||
var tpl = ec('a'); | ||
expect(tpl.render({})).to.be('a'); | ||
}); | ||
it('"a "', function(){ | ||
var tpl = ec('a '); | ||
expect(tpl.render({})).to.be('a '); | ||
}); | ||
it('" a"', function(){ | ||
var tpl = ec(' a'); | ||
expect(tpl.render({})).to.be(' a'); | ||
}); | ||
it('" a "', function(){ | ||
var tpl = ec(' a '); | ||
expect(tpl.render({})).to.be(' a '); | ||
}); | ||
it('"{{=a"', function() { | ||
var tpl = ec('{{=a'); | ||
expect(tpl.render({})).to.be('{{=a'); | ||
}); | ||
it('"a{{="', function() { | ||
var tpl = ec('a{{='); | ||
expect(tpl.render({})).to.be('a{{='); | ||
}); | ||
it('"{{=a{{="', function() { | ||
var tpl = ec('{{=a{{='); | ||
expect(tpl.render({})).to.be('{{=a{{='); | ||
}); | ||
it('"}}a"', function() { | ||
var tpl = ec('}}a'); | ||
expect(tpl.render({})).to.be('}}a'); | ||
}); | ||
it('"a}}"', function() { | ||
var tpl = ec('a}}'); | ||
expect(tpl.render({})).to.be('a}}'); | ||
}); | ||
it('"{{=}}"', function() { | ||
var tpl = ec('{{=}}'); | ||
expect(tpl.render({})).to.be('{{=}}'); | ||
}); | ||
}); | ||
describe('variable', function () { | ||
beforeEach(function () { | ||
@@ -14,45 +60,31 @@ // eoraptor.cache = {}; | ||
it('no expression: foo', function(){ | ||
var tpl = ec('foo'); | ||
expect(tpl.render({})).to.be('foo'); | ||
}); | ||
it(' no expression: " foo "', function(){ | ||
var tpl = ec(' foo '); | ||
expect(tpl.render({})).to.be(' foo '); | ||
}); | ||
it('variable: a{{=b{{=c}}', function(){ | ||
var tpl = ec('a{{=b{{=c}}'); | ||
var ret = tpl({ | ||
c: 'c' | ||
}); | ||
expect(ret).to.be('a{{=bc'); | ||
}); | ||
it('eoraptor.foo.source', function(){ | ||
var tpl = ec('foo', {id:'fooTpl'}); | ||
expect(tpl.source).to.be(eoraptor.fooTpl.source); | ||
}); | ||
it('variable: {{=foo}}', function(){ | ||
var tpl = ec('{{=foo}}'); | ||
var ret = tpl({foo:'v'}); | ||
// it('eoraptor.a.source', function(){ | ||
// var tpl = ec('a', {id:'aTpl'}); | ||
// expect(tpl.source).to.be(eoraptor.aTpl.source); | ||
// }); | ||
it('"{{=a}}"', function(){ | ||
var tpl = ec('{{=a}}'); | ||
var ret = tpl({a:'v'}); | ||
expect(ret).to.be('v'); | ||
}); | ||
it('variable: {{= foo }}', function(){ | ||
var tpl = ec('{{= foo }}'); | ||
var ret = tpl({foo:'v'}); | ||
it('"{{= a }}"', function(){ | ||
var tpl = ec('{{= a }}'); | ||
var ret = tpl({a:'v'}); | ||
expect(ret).to.be('v'); | ||
}); | ||
it('variable: {{=["foo"]}}', function(){ | ||
var tpl = ec('{{=["foo"]}}'); | ||
it('"{{=["a"]}}"', function(){ | ||
var tpl = ec('{{=["a"]}}'); | ||
var ret = tpl({ | ||
foo: 'v' | ||
a: 'v' | ||
}); | ||
expect(ret).to.be('v'); | ||
}); | ||
it("variable: {{=['foo']}}", function(){ | ||
var tpl = ec("{{=['foo']}}"); | ||
it('"{{=[\'a\']}}"', function(){ | ||
var tpl = ec("{{=['a']}}"); | ||
var ret = tpl({ | ||
foo: 'v' | ||
a: 'v' | ||
}); | ||
@@ -62,26 +94,33 @@ expect(ret).to.be('v'); | ||
it('variable: {{=["foo\\\"foo"]}}', function(){ | ||
var tpl = ec('{{=["foo\\\"foo"]}}'); | ||
it('quote escaped in template, "{{=["a\\\"a"]}}"', function(){ | ||
var tpl = ec('{{=["a\\\"a"]}}'); | ||
var ret = tpl({ | ||
'foo"foo': 'v' | ||
'a"a': 'v' | ||
}); | ||
expect(ret).to.be('v'); | ||
}); | ||
it('key with "-": {{=["first-name"]}}', function(){ | ||
it('"-" in template, {{=["first-name"]}}', function(){ | ||
var tpl = ec('{{=["first-name"]}}'); | ||
var ret = tpl({'first-name':'foo'}); | ||
expect(ret).to.be('foo'); | ||
var ret = tpl({'first-name':'a'}); | ||
expect(ret).to.be('a'); | ||
}); | ||
it('variable: "{{=foo.boo}}"', function(){ | ||
var tpl = ec('{{=foo.boo}}'); | ||
it('"a{{=b{{=c}}"', function(){ | ||
var tpl = ec('a{{=b{{=c}}'); | ||
var ret = tpl({ | ||
foo: { boo: 'v' } | ||
c: 'c' | ||
}); | ||
expect(ret).to.be('a{{=bc'); | ||
}); | ||
it('"{{=a.b}}"', function(){ | ||
var tpl = ec('{{=a.b}}'); | ||
var ret = tpl({ | ||
a: { b: 'v' } | ||
}); | ||
expect(ret).to.be('v'); | ||
}); | ||
it('{{=foo}}, no such key', function(){ | ||
var tpl = ec('{{=foo}}'); | ||
it('key is missing', function(){ | ||
var tpl = ec('{{=a}}'); | ||
var ret = tpl({}); | ||
@@ -91,33 +130,28 @@ expect(ret).to.be(''); | ||
it('escape', function(){ | ||
var tpl = ec('{{=foo}}'); | ||
var ret = tpl({foo: 'hello "eoraptor"'}); | ||
it('output escaped value', function(){ | ||
var tpl = ec('{{=a}}'); | ||
var ret = tpl({a: 'hello "eoraptor"'}); | ||
expect(ret).to.be('hello "eoraptor"'); | ||
}); | ||
it('no-escape', function(){ | ||
var tpl = ec('{{-foo}}'); | ||
var ret = tpl({foo: 'hello "eoraptor"'}); | ||
it('output unescaped value', function(){ | ||
var tpl = ec('{{-a}}'); | ||
var ret = tpl({a: 'hello "eoraptor"'}); | ||
expect(ret).to.be('hello "eoraptor"'); | ||
}); | ||
it('html', function(){ | ||
var tpl = ec('{{-foo}}'); | ||
var ret = tpl({foo:'<h1>foo</h1>'}); | ||
expect(ret).to.be('<h1>foo</h1>'); | ||
it('output unescaped value: html', function(){ | ||
var tpl = ec('{{-a}}'); | ||
var ret = tpl({a:'<h1>a</h1>'}); | ||
expect(ret).to.be('<h1>a</h1>'); | ||
}); | ||
it('w:{{=w}}, h:{{=h}}', function(){ | ||
var tpl = ec('w:{{=w}}, h:{{=h}}'); | ||
var ret = tpl({ | ||
w:10, | ||
h:20 | ||
}); | ||
// console.log(tpl.source); | ||
expect(ret).to.be('w:10, h:20'); | ||
}); | ||
}); | ||
it('iterate an array', function(){ | ||
describe('iterating array', function () { | ||
it('normal', function(){ | ||
var tpl = ec('{{^list item key}}'+ | ||
'<i>{{=&item}}</i>'+ | ||
'{{=&item}}{{=&key}}'+ | ||
'{{/}}'); | ||
@@ -127,8 +161,8 @@ var ret = tpl({ | ||
}); | ||
expect(ret).to.be('<i>a</i><i>b</i><i>c</i>'); | ||
expect(ret).to.be('a0b1c2'); | ||
}); | ||
it('iterate an array, key with "-"', function(){ | ||
it('key with "-"', function(){ | ||
var tpl = ec('{{^["list-foo"] item key}}'+ | ||
'<i>{{=&item}}</i>'+ | ||
'{{=&item}}{{=&key}}'+ | ||
'{{/}}'); | ||
@@ -138,3 +172,3 @@ var ret = tpl({ | ||
}); | ||
expect(ret).to.be('<i>a</i><i>b</i><i>c</i>'); | ||
expect(ret).to.be('a0b1c2'); | ||
}); | ||
@@ -153,2 +187,13 @@ | ||
it('iterating &array', function () { | ||
var list = ['a', 'b', 'c']; | ||
var tpl = ec('{{^&list item}}{{=&item}}{{=&key}}{{/}}'); | ||
var ret = tpl({}); | ||
expect(ret).to.be('a0b1c2'); | ||
}); | ||
}); | ||
describe('iterating object', function () { | ||
it('iterate an object', function(){ | ||
@@ -155,0 +200,0 @@ var tpl = ec('<ul>'+ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
240338
20
7457
1