1
0
mirror of https://github.com/bobwen-dev/react-templates synced 2025-04-12 00:56:39 +02:00

Merge pull request #89 from nippur72/safe-parsing

Correctly parse rt-repeat object literal collection
This commit is contained in:
Avi Marcus 2016-01-13 12:10:43 +02:00
commit b67efbf278
4 changed files with 8 additions and 2 deletions

View File

@ -346,7 +346,7 @@ function convertHtmlToReact(node, context) {
data.item = arr[0].trim(); data.item = arr[0].trim();
data.collection = arr[1].trim(); data.collection = arr[1].trim();
validateJS(data.item, node, context); validateJS(data.item, node, context);
validateJS(data.collection, node, context); validateJS("(" + data.collection + ")", node, context);
stringUtils.addIfMissing(context.boundParams, data.item); stringUtils.addIfMissing(context.boundParams, data.item);
stringUtils.addIfMissing(context.boundParams, `${data.item}Index`); stringUtils.addIfMissing(context.boundParams, `${data.item}Index`);
} }

View File

@ -0,0 +1,5 @@
<div>
<div rt-repeat="items in {a:1, b:2}">
{items}
</div>
</div>

View File

@ -0,0 +1 @@
<div><div>1</div><div>2</div></div>

View File

@ -184,7 +184,7 @@ test('convert jsrt and test source results', function (t) {
test('html tests', function (t) { test('html tests', function (t) {
var files = ['scope.rt', 'scope-trailing-semicolon.rt', 'scope-variable-references.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt', var files = ['scope.rt', 'scope-trailing-semicolon.rt', 'scope-variable-references.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt',
'js-in-attr.rt', 'props-class.rt', 'rt-class.rt', 'className.rt', 'svg.rt', 'js-in-attr.rt', 'props-class.rt', 'rt-class.rt', 'className.rt', 'svg.rt',
'scope-evaluated-after-repeat.rt', 'scope-evaluated-after-repeat2.rt', 'scope-evaluated-after-if.rt', 'scope-obj.rt' 'repeat-literal-collection.rt', 'scope-evaluated-after-repeat.rt', 'scope-evaluated-after-repeat2.rt', 'scope-evaluated-after-if.rt', 'scope-obj.rt'
]; ];
t.plan(files.length); t.plan(files.length);