mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixed support for <attr> and <assign> tags
This commit is contained in:
parent
2267e790b0
commit
c34ba4dd49
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<div data-attr="Hello <John> <hello>">
|
<div data-attr="Hello <John> <hello>">
|
||||||
<c-attr name="data-nested-attr">Hello <John> <![CDATA[<hello>]]></c-attr>
|
<attr name="data-nested-attr">Hello <John> <![CDATA[<hello>]]></attr>
|
||||||
<c-attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
<attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
||||||
Hello <John>© <![CDATA[<hello>]]>
|
Hello <John>© <![CDATA[<hello>]]>
|
||||||
${startTag:START}
|
${startTag:START}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -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>
|
||||||
@ -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>
|
||||||
@ -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
|
||||||
|
|||||||
@ -9,8 +9,8 @@ $name
|
|||||||
<div title="$welcome <hello>" data-name="$name"/>
|
<div title="$welcome <hello>" data-name="$name"/>
|
||||||
|
|
||||||
<div data-attr="Hello $name <hello>">
|
<div data-attr="Hello $name <hello>">
|
||||||
<c-attr name="data-nested-attr"><Hello> $name <![CDATA[<hello>]]></c-attr>
|
<attr name="data-nested-attr"><Hello> $name <![CDATA[<hello>]]></attr>
|
||||||
<c-attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
<attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
||||||
Hello <John>© <![CDATA[<hello>]]>
|
Hello <John>© <![CDATA[<hello>]]>
|
||||||
${startTag:START}
|
${startTag:START}
|
||||||
</div>
|
</div>
|
||||||
@ -1,8 +1,8 @@
|
|||||||
<c-template
|
<c-template
|
||||||
params="">
|
params="">
|
||||||
<div data-attr="Hello <John> <hello>">
|
<div data-attr="Hello <John> <hello>">
|
||||||
<c-attr name="data-nested-attr">Hello <John> <![CDATA[<hello>]]></c-attr>
|
<attr name="data-nested-attr">Hello <John> <![CDATA[<hello>]]></attr>
|
||||||
<c-attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
<attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
||||||
Hello <John>© <![CDATA[<hello>]]>
|
Hello <John>© <![CDATA[<hello>]]>
|
||||||
${startTag:START}
|
${startTag:START}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -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>
|
||||||
@ -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>
|
||||||
@ -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
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
<div title="$welcome <hello>" data-name="$name"/>
|
<div title="$welcome <hello>" data-name="$name"/>
|
||||||
|
|
||||||
<div data-attr="Hello $name <hello>">
|
<div data-attr="Hello $name <hello>">
|
||||||
<c-attr name="data-nested-attr"><Hello> $name <![CDATA[<hello>]]></c-attr>
|
<attr name="data-nested-attr"><Hello> $name <![CDATA[<hello>]]></attr>
|
||||||
<c-attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
<attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
||||||
Hello <John>© <![CDATA[<hello>]]>
|
Hello <John>© <![CDATA[<hello>]]>
|
||||||
${startTag:START}
|
${startTag:START}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user