Merge pull request #44 from anchann/rt-scope-trailing-semicolon

Allow trailing semicolon in rt-scope
This commit is contained in:
Avi Marcus 2015-07-29 08:34:46 +03:00
commit b79ed7a040
4 changed files with 11 additions and 1 deletions

View File

@ -293,6 +293,8 @@ function convertHtmlToReact(node, context) {
data.scopeMapping[boundParam] = boundParam;
});
_.each(node.attribs[scopeProp].split(';'), function (scopePart) {
if (scopePart.trim().length === 0) return;
var scopeSubParts = scopePart.split(' as ');
if (scopeSubParts.length < 2) {
throw RTCodeError.build("invalid scope part '" + scopePart + "'", context, node);

View File

@ -0,0 +1,6 @@
<div>
<div rt-scope="15 as a; 20 as b;">
{a + b}
</div>
<div rt-if="typeof a === 'undefined'">good</div>
</div>

View File

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

View File

@ -175,7 +175,7 @@ function normalizeHtml(html) {
}
test('html tests', function (t) {
var files = ['scope.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt', 'js-in-attr.rt', 'props-class.rt', 'rt-class.rt'];
var files = ['scope.rt', 'scope-trailing-semicolon.rt', 'lambda.rt', 'eval.rt', 'props.rt', 'custom-element.rt', 'style.rt', 'concat.rt', 'js-in-attr.rt', 'props-class.rt', 'rt-class.rt'];
t.plan(files.length);
files.forEach(check);