mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Added more tests for array looping
This commit is contained in:
parent
fb572c9b6e
commit
4d8c95104b
22
test/autotests/compiler/for-array/expected.js
Normal file
22
test/autotests/compiler/for-array/expected.js
Normal 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);
|
||||
2
test/autotests/compiler/for-array/template.marko
Normal file
2
test/autotests/compiler/for-array/template.marko
Normal file
@ -0,0 +1,2 @@
|
||||
for(color in ['red', 'green', 'blue'] | array)
|
||||
- ${color}
|
||||
@ -1 +1 @@
|
||||
<div data-encoding=""hello"" style="background-color: #FF0000; <test>" class="my-div" checked>Hello World!</div>
|
||||
<div data-encoding=""hello"" style="background-color: #FF0000; <test>" class="my-div" checked>Hello World!</div>
|
||||
@ -1 +1 @@
|
||||
<div data-attr="Hello "John" <foo>">Hello <John>© <hello></div> ©
|
||||
<div data-attr="Hello "John" <foo>">Hello <John>© <hello></div> ©
|
||||
@ -0,0 +1 @@
|
||||
<div>red</div><div>green</div><div>blue</div>
|
||||
@ -0,0 +1,5 @@
|
||||
<for(color in data.colors | array)>
|
||||
<div>
|
||||
${color}
|
||||
</div>
|
||||
</for>
|
||||
3
test/autotests/render/for-tag-array-expression/test.js
Normal file
3
test/autotests/render/for-tag-array-expression/test.js
Normal file
@ -0,0 +1,3 @@
|
||||
exports.templateData = {
|
||||
colors: ['red', 'green', 'blue']
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user