Fixed support for using native for loops

This commit is contained in:
Patrick Steele-Idem 2015-02-04 17:26:18 -07:00
parent df86ec83ae
commit 2ac6d56a8e
4 changed files with 19 additions and 6 deletions

View File

@ -234,7 +234,9 @@ ForNode.prototype = {
}
}, this).line('});');
} else {
if (this.getProperty('forLoop') === true) {
var forLoopProp = this.getProperty('forLoop');
if (forLoopProp && forLoopProp.toString() === 'true') {
forEachParams = [
'__array',
'__index',

View File

@ -159,6 +159,10 @@ describe('marko/marko' , function() {
testRender("test-project/html-templates/looping.marko", {}, done);
});
it.only("should allow for looping (native for-loop)", function(done) {
testRender("test-project/html-templates/looping-native-for-loop.marko", {}, done);
});
it("should allow for looping over properties", function(done) {
testRender("test-project/html-templates/looping-props.marko", {}, done);
});

View File

@ -0,0 +1,6 @@
<for each="item in ['a', 'b', 'c']" for-loop="true">
${item}
</for>
<div for="item in ['red', 'green', 'blue']; for-loop=true" >
${item}
</div>

View File

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