Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for <foreach>. Tested and works.

  • Loading branch information...
commit ec8108c207b05faed6b0a37fa5bde7f3c3979b82 1 parent 134d158
@jbeard4 authored
View
16 lib/core/util/action-code-generator.js
@@ -26,7 +26,7 @@ var codeGenerators = {
},
"assign" : function(attributes,children){
- return attributes.location + " = " + attributes.expr;
+ return attributes.location + " = " + attributes.expr + ";";
},
"if" : function(attributes,children){
@@ -108,6 +108,20 @@ var codeGenerators = {
"delay: " + (attributes.delayexpr ? attributes.delayexpr : getDelayInMs(attributes.delay)) + ",\n" +
"sendId: " + (attributes.idlocation ? attributes.idlocation : JSON.stringify(attributes.id)) + "\n" +
"});";
+ },
+
+ "foreach" : function(attributes,children){
+ var isIndexDefined = attributes.index,
+ index = attributes.index || "$i", //FIXME: the index variable could shadow the datamodel. We should pick a unique temperorary variable name
+ item = attributes.item,
+ arr = attributes.array;
+
+ return "(function(){\n" +
+ "for(" + (isIndexDefined ? "" : "var " + index + " = 0") + "; " + index + " < " + arr + ".length; " + index + "++){\n" +
+ item + " = " + arr + "[" + index + "];\n" +
+ children.filter(Array.isArray).map(_generateCode).join("\n;;\n") +
+ "\n}\n" +
+ "})();";
}
};
2  test/scxml-test-framework
@@ -1 +1 @@
-Subproject commit 6e83c2313a9b01a3ba68de4b8f71df09f2f0eacf
+Subproject commit 67353d2c2574b592d6b74acd26fdc04e0453ef63
Please sign in to comment.
Something went wrong with that request. Please try again.