mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #167 - Nested tags only work one level deep
This commit is contained in:
parent
032a5da4fa
commit
f98a7dfef9
@ -5,6 +5,14 @@ Changelog
|
|||||||
|
|
||||||
## 2.7.x
|
## 2.7.x
|
||||||
|
|
||||||
|
### 2.7.31
|
||||||
|
|
||||||
|
- Fixes #167 - Nested tags only work one level deep
|
||||||
|
|
||||||
|
### 2.7.30
|
||||||
|
|
||||||
|
- docs: don't exclude docs in .npmignore
|
||||||
|
|
||||||
### 2.7.29
|
### 2.7.29
|
||||||
|
|
||||||
- Fixes #161 - Nested tags with no body content are not handled correctly
|
- Fixes #161 - Nested tags with no body content are not handled correctly
|
||||||
|
|||||||
@ -100,9 +100,9 @@ TaglibLookup.prototype = {
|
|||||||
|
|
||||||
var merged = this.merged;
|
var merged = this.merged;
|
||||||
|
|
||||||
function handleNestedTag(nestedTag, parentTagName) {
|
function handleNestedTags(tag, parentTagName) {
|
||||||
|
tag.forEachNestedTag(function(nestedTag) {
|
||||||
var fullyQualifiedName = parentTagName + '.' + nestedTag.name;
|
var fullyQualifiedName = parentTagName + '.' + nestedTag.name;
|
||||||
|
|
||||||
// Create a clone of the nested tag since we need to add some new
|
// Create a clone of the nested tag since we need to add some new
|
||||||
// properties
|
// properties
|
||||||
var clonedNestedTag = new Tag();
|
var clonedNestedTag = new Tag();
|
||||||
@ -112,12 +112,12 @@ TaglibLookup.prototype = {
|
|||||||
clonedNestedTag.parentTagName = parentTagName;
|
clonedNestedTag.parentTagName = parentTagName;
|
||||||
clonedNestedTag.name = fullyQualifiedName;
|
clonedNestedTag.name = fullyQualifiedName;
|
||||||
merged.tags[fullyQualifiedName] = clonedNestedTag;
|
merged.tags[fullyQualifiedName] = clonedNestedTag;
|
||||||
|
handleNestedTags(clonedNestedTag, fullyQualifiedName);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
taglib.forEachTag(function(tag) {
|
taglib.forEachTag(function(tag) {
|
||||||
tag.forEachNestedTag(function(nestedTag) {
|
handleNestedTags(tag, tag.name);
|
||||||
handleNestedTag(nestedTag, tag.name);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -153,6 +153,7 @@ TagHandlerNode.prototype = {
|
|||||||
|
|
||||||
var nestedTagVar;
|
var nestedTagVar;
|
||||||
var nestedTagParentNode = null;
|
var nestedTagParentNode = null;
|
||||||
|
var parentNestedTagVar;
|
||||||
|
|
||||||
if (isNestedTag) {
|
if (isNestedTag) {
|
||||||
nestedTagParentNode = getNestedTagParentNode(this, tag);
|
nestedTagParentNode = getNestedTagParentNode(this, tag);
|
||||||
@ -161,7 +162,7 @@ TagHandlerNode.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nestedTagVar = nestedTagParentNode.data.nestedTagVar;
|
parentNestedTagVar = nestedTagParentNode.data.nestedTagVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNestedTags) {
|
if (hasNestedTags) {
|
||||||
@ -314,7 +315,7 @@ TagHandlerNode.prototype = {
|
|||||||
|
|
||||||
if (isNestedTag) {
|
if (isNestedTag) {
|
||||||
options.push('targetProperty: ' + JSON.stringify(tag.targetProperty));
|
options.push('targetProperty: ' + JSON.stringify(tag.targetProperty));
|
||||||
options.push('parent: ' + nestedTagVar);
|
options.push('parent: ' + parentNestedTagVar);
|
||||||
if (tag.isRepeated) {
|
if (tag.isRepeated) {
|
||||||
options.push('isRepeated: 1');
|
options.push('isRepeated: 1');
|
||||||
}
|
}
|
||||||
|
|||||||
3
test/fixtures/marko-taglib.json
vendored
3
test/fixtures/marko-taglib.json
vendored
@ -122,5 +122,6 @@
|
|||||||
"taglib-imports": ["./package.json", "./nested-import/marko-taglib.json"],
|
"taglib-imports": ["./package.json", "./nested-import/marko-taglib.json"],
|
||||||
"<test-invalid-attr>": {
|
"<test-invalid-attr>": {
|
||||||
"@foo": "string"
|
"@foo": "string"
|
||||||
}
|
},
|
||||||
|
"<test-nested-tags-deep>": "./taglib/test-nested-tags-deep/marko-tag.json"
|
||||||
}
|
}
|
||||||
10
test/fixtures/taglib/test-nested-tags-deep/marko-tag.json
vendored
Normal file
10
test/fixtures/taglib/test-nested-tags-deep/marko-tag.json
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"renderer": "./renderer",
|
||||||
|
"@class": "string",
|
||||||
|
"@items <item>[]": {
|
||||||
|
"@foo": "string",
|
||||||
|
"@body <body>": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
test/fixtures/taglib/test-nested-tags-deep/renderer.js
vendored
Normal file
5
test/fixtures/taglib/test-nested-tags-deep/renderer.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
var template = require('./template.marko');
|
||||||
|
|
||||||
|
module.exports = function(input, out) {
|
||||||
|
template.render(input, out);
|
||||||
|
};
|
||||||
4
test/fixtures/taglib/test-nested-tags-deep/template.marko
vendored
Normal file
4
test/fixtures/taglib/test-nested-tags-deep/template.marko
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div for="item in data.items">
|
||||||
|
Foo: ${item.foo}
|
||||||
|
Body: <invoke function="item.body.renderBody(out)" if="item.body"/>
|
||||||
|
</div>
|
||||||
1
test/fixtures/templates/nested-tags-deep/expected.html
vendored
Normal file
1
test/fixtures/templates/nested-tags-deep/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div>Foo: bar Body: <b>Deeply nested!</b></div><div>Foo: baz Body: <b>Another deeply nested!</b></div>
|
||||||
12
test/fixtures/templates/nested-tags-deep/template.marko
vendored
Normal file
12
test/fixtures/templates/nested-tags-deep/template.marko
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<test-nested-tags-deep class="nested-tags-deep">
|
||||||
|
<test-nested-tags-deep.item foo="bar">
|
||||||
|
<test-nested-tags-deep.item.body>
|
||||||
|
<b>Deeply nested!</b>
|
||||||
|
</test-nested-tags-deep.item.body>
|
||||||
|
</test-nested-tags-deep.item>
|
||||||
|
<test-nested-tags-deep.item foo="baz">
|
||||||
|
<test-nested-tags-deep.item.body>
|
||||||
|
<b>Another deeply nested!</b>
|
||||||
|
</test-nested-tags-deep.item.body>
|
||||||
|
</test-nested-tags-deep.item>
|
||||||
|
</test-nested-tags-deep>
|
||||||
1
test/fixtures/templates/nested-tags-deep/test.js
vendored
Normal file
1
test/fixtures/templates/nested-tags-deep/test.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
Loading…
x
Reference in New Issue
Block a user