Added more tests for array looping

This commit is contained in:
Patrick Steele-Idem 2016-10-28 12:11:23 -06:00
parent fb572c9b6e
commit 4d8c95104b
7 changed files with 35 additions and 2 deletions

View File

@ -0,0 +1,22 @@
function create(__markoHelpers) {
var marko_escapeXml = __markoHelpers.x;
return function render(data, out) {
var color,
color__i,
color__array,
color__len;
for (color__i = 0, color__array = [
"red",
"green",
"blue"
], color__len = color__array && color__array.length; color__i < color__len; color__i++) {
color = color__array[color__i];
out.w(marko_escapeXml(color));
}
};
}
module.exports = require("marko/html").c(__filename, create);

View File

@ -0,0 +1,2 @@
for(color in ['red', 'green', 'blue'] | array)
- ${color}

View File

@ -1 +1 @@
<div data-encoding="&quot;hello&quot;" style="background-color: #FF0000; &lt;test&gt;" class="my-div" checked>Hello World!</div>
<div data-encoding="&quot;hello&quot;" style="background-color: #FF0000; &lt;test>" class="my-div" checked>Hello World!</div>

View File

@ -1 +1 @@
<div data-attr="Hello &quot;John&quot; &lt;foo&gt;">Hello &lt;John&gt;© &lt;hello></div> &copy;
<div data-attr="Hello &quot;John&quot; &lt;foo>">Hello &lt;John&gt;© &lt;hello></div> &copy;

View File

@ -0,0 +1 @@
<div>red</div><div>green</div><div>blue</div>

View File

@ -0,0 +1,5 @@
<for(color in data.colors | array)>
<div>
${color}
</div>
</for>

View File

@ -0,0 +1,3 @@
exports.templateData = {
colors: ['red', 'green', 'blue']
};