diff --git a/src/reactTemplates.js b/src/reactTemplates.js index d2946e2..4de2848 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -112,6 +112,9 @@ function generateProps(node, context) { } var res = str.split(":"); res[0] = res[0].trim(); + if (res[0].indexOf("-") != -1) { + res[0] = "\"" + res[0] + "\""; + } res[1] = res[1].trim(); return res; })); @@ -143,6 +146,11 @@ function defaultContext() { }; } +function addIfNotThere(array, obj) { + if (!_.contains(array, obj)) { + array.push(obj); + } +} function convertHtmlToReact(node, context) { if (node.type === "tag") { @@ -155,7 +163,8 @@ function convertHtmlToReact(node, context) { if (node.attribs[templateProp]) { data.item = node.attribs[templateProp].split(" in ")[0].trim(); data.collection = node.attribs[templateProp].split(" in ")[1].trim(); - context.boundParams.push(data.item); + addIfNotThere(context.boundParams, data.item); + addIfNotThere(context.boundParams, data.item + "Index"); } data.props = generateProps(node, context); if (node.attribs[ifProp]) { diff --git a/test/data/repeat.html b/test/data/repeat.html new file mode 100644 index 0000000..22ff667 --- /dev/null +++ b/test/data/repeat.html @@ -0,0 +1,6 @@ + +
+