Fixed support for <attr> and <assign> tags

This commit is contained in:
Patrick Steele-Idem 2014-10-22 13:24:46 -06:00
parent 2267e790b0
commit c34ba4dd49
12 changed files with 34 additions and 34 deletions

View File

@ -214,7 +214,7 @@ function handleAttr(node, compiler, template) {
node.addError('Invalid attributes for tag ' + node.toString() + ': ' + invalidAttrs.join(', ')); node.addError('Invalid attributes for tag ' + node.toString() + ': ' + invalidAttrs.join(', '));
return; return;
} }
//Cleanup whitespace between <c-attr> tags //Cleanup whitespace between <attr> tags
if (node.previousSibling && node.previousSibling.isTextNode() && node.previousSibling.getText().trim() === '') { if (node.previousSibling && node.previousSibling.isTextNode() && node.previousSibling.getText().trim() === '') {
node.previousSibling.detach(); node.previousSibling.detach();
} }
@ -238,7 +238,7 @@ function handleAttr(node, compiler, template) {
function findNestedAttrs(node, compiler, template) { function findNestedAttrs(node, compiler, template) {
node.forEachChild(function (child) { node.forEachChild(function (child) {
if (child.qName === 'c-attr') { if (child.qName === 'attr') {
handleAttr(child, compiler, template); handleAttr(child, compiler, template);
} }
}); });

View File

@ -191,7 +191,7 @@
} }
} }
}, },
"c-attr": { "attr": {
"attributes": { "attributes": {
"name": { "name": {
"type": "string" "type": "string"
@ -243,7 +243,7 @@
} }
} }
}, },
"c-assign": { "assign": {
"node-class": "./AssignNode", "node-class": "./AssignNode",
"attributes": { "attributes": {
"var": { "var": {

View File

@ -1,6 +1,6 @@
<div data-attr="Hello &lt;John&gt; &lt;hello&gt;"> <div data-attr="Hello &lt;John&gt; &lt;hello&gt;">
<c-attr name="data-nested-attr">Hello &lt;John&gt; <![CDATA[<hello>]]></c-attr> <attr name="data-nested-attr">Hello &lt;John&gt; <![CDATA[<hello>]]></attr>
<c-attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/> <attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/>
Hello &lt;John&gt;© <![CDATA[<hello>]]> Hello &lt;John&gt;© <![CDATA[<hello>]]>
${startTag:START} ${startTag:START}
</div> </div>

View File

@ -75,11 +75,11 @@ INVALID
</else> </else>
<div class="test"> <div class="test">
<c-attr name="class" value="duplicate"/> <attr name="class" value="duplicate"/>
</div> </div>
<test-popover title="Popover Title" invalidAttr1="invalidValue1"> <test-popover title="Popover Title" invalidAttr1="invalidValue1">
<c-attr name="invalidAttr2" value="invalidValue2"/> <attr name="invalidAttr2" value="invalidValue2"/>
<c-attr name="invalidAttr3">invalidValue3</c-attr> <attr name="invalidAttr3">invalidValue3</attr>
<c-attr name="invalidAttr4" if="invalidIf">invalidValue4</c-attr> <attr name="invalidAttr4" if="invalidIf">invalidValue4</attr>
</test-popover> </test-popover>

View File

@ -1,19 +1,19 @@
<var name="active" value="data.active"/> <var name="active" value="data.active"/>
<test-popover> <test-popover>
<c-attr name="title">Popover Title</c-attr> <attr name="title">Popover Title</attr>
<c-attr name="content">Popover Content</c-attr> <attr name="content">Popover Content</attr>
Link Text Link Text
</test-popover> </test-popover>
<div> <div>
<c-attr name="class" value="{?active;tab-active}"/> <attr name="class" value="{?active;tab-active}"/>
<c-attr name="align">center</c-attr> <attr name="align">center</attr>
</div> </div>
<div> <div>
<c-attr name="title"> <attr name="title">
<for each="color in ['red', 'green', 'blue']"> $color! </for> <for each="color in ['red', 'green', 'blue']"> $color! </for>
</c-attr> </attr>
</div> </div>

View File

@ -4,7 +4,7 @@
$color $color
</div> </div>
<c-assign var="colors" value="['orange', 'purple', 'yellow']"/> <assign var="colors" value="['orange', 'purple', 'yellow']"/>
<div for="color in colors"> <div for="color in colors">
$color $color

View File

@ -9,8 +9,8 @@ $name
<div title="$welcome &lt;hello&gt;" data-name="$name"/> <div title="$welcome &lt;hello&gt;" data-name="$name"/>
<div data-attr="Hello $name &lt;hello&gt;"> <div data-attr="Hello $name &lt;hello&gt;">
<c-attr name="data-nested-attr">&lt;Hello> $name <![CDATA[<hello>]]></c-attr> <attr name="data-nested-attr">&lt;Hello> $name <![CDATA[<hello>]]></attr>
<c-attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/> <attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/>
Hello &lt;John&gt;© <![CDATA[<hello>]]> Hello &lt;John&gt;© <![CDATA[<hello>]]>
${startTag:START} ${startTag:START}
</div> </div>

View File

@ -1,8 +1,8 @@
<c-template <c-template
params=""> params="">
<div data-attr="Hello &lt;John&gt; &lt;hello&gt;"> <div data-attr="Hello &lt;John&gt; &lt;hello&gt;">
<c-attr name="data-nested-attr">Hello &lt;John&gt; <![CDATA[<hello>]]></c-attr> <attr name="data-nested-attr">Hello &lt;John&gt; <![CDATA[<hello>]]></attr>
<c-attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/> <attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/>
Hello &lt;John&gt;© <![CDATA[<hello>]]> Hello &lt;John&gt;© <![CDATA[<hello>]]>
${startTag:START} ${startTag:START}
</div> </div>

View File

@ -79,12 +79,12 @@
</else> </else>
<div class="test"> <div class="test">
<c-attr name="class" value="duplicate"/> <attr name="class" value="duplicate"/>
</div> </div>
<test-popover title="Popover Title" invalidAttr1="invalidValue1"> <test-popover title="Popover Title" invalidAttr1="invalidValue1">
<c-attr name="invalidAttr2" value="invalidValue2"/> <attr name="invalidAttr2" value="invalidValue2"/>
<c-attr name="invalidAttr3">invalidValue3</c-attr> <attr name="invalidAttr3">invalidValue3</attr>
<c-attr name="invalidAttr4" if="invalidIf">invalidValue4</c-attr> <attr name="invalidAttr4" if="invalidIf">invalidValue4</attr>
</test-popover> </test-popover>
</c-template> </c-template>

View File

@ -2,20 +2,20 @@
params="active"> params="active">
<test-popover> <test-popover>
<c-attr name="title">Popover Title</c-attr> <attr name="title">Popover Title</attr>
<c-attr name="content">Popover Content</c-attr> <attr name="content">Popover Content</attr>
Link Text Link Text
</test-popover> </test-popover>
<div> <div>
<c-attr name="class" value="{?active;tab-active}"/> <attr name="class" value="{?active;tab-active}"/>
<c-attr name="align">center</c-attr> <attr name="align">center</attr>
</div> </div>
<div> <div>
<c-attr name="title"> <attr name="title">
<for each="color in ['red', 'green', 'blue']"> $color! </for> <for each="color in ['red', 'green', 'blue']"> $color! </for>
</c-attr> </attr>
</div> </div>
</c-template> </c-template>

View File

@ -6,7 +6,7 @@
$color $color
</div> </div>
<c-assign var="colors" value="['orange', 'purple', 'yellow']"/> <assign var="colors" value="['orange', 'purple', 'yellow']"/>
<div for="color in colors"> <div for="color in colors">
$color $color

View File

@ -9,8 +9,8 @@
<div title="$welcome &lt;hello&gt;" data-name="$name"/> <div title="$welcome &lt;hello&gt;" data-name="$name"/>
<div data-attr="Hello $name &lt;hello&gt;"> <div data-attr="Hello $name &lt;hello&gt;">
<c-attr name="data-nested-attr">&lt;Hello> $name <![CDATA[<hello>]]></c-attr> <attr name="data-nested-attr">&lt;Hello> $name <![CDATA[<hello>]]></attr>
<c-attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/> <attr name="data-nested-attr2" value="Hello &lt;John&gt; &lt;hello&gt;"/>
Hello &lt;John&gt;© <![CDATA[<hello>]]> Hello &lt;John&gt;© <![CDATA[<hello>]]>
${startTag:START} ${startTag:START}
</div> </div>