Merge branch 'master' of github.com:marko-js/marko into htmljs-parser

This commit is contained in:
Patrick Steele-Idem 2015-12-07 14:03:23 -07:00
commit 76f1a5998a
9 changed files with 57 additions and 16 deletions

View File

@ -5,6 +5,14 @@ Changelog
## 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
- Fixes #161 - Nested tags with no body content are not handled correctly

View File

@ -99,24 +99,24 @@ class TaglibLookup {
var merged = this.merged;
function handleNestedTag(nestedTag, parentTagName) {
var fullyQualifiedName = parentTagName + '.' + nestedTag.name;
// Create a clone of the nested tag since we need to add some new
// properties
var clonedNestedTag = new Tag();
extend(clonedNestedTag ,nestedTag);
// Record the fully qualified name of the parent tag that this
// custom tag is associated with.
clonedNestedTag.parentTagName = parentTagName;
clonedNestedTag.name = fullyQualifiedName;
merged.tags[fullyQualifiedName] = clonedNestedTag;
function handleNestedTags(tag, parentTagName) {
tag.forEachNestedTag(function(nestedTag) {
var fullyQualifiedName = parentTagName + '.' + nestedTag.name;
// Create a clone of the nested tag since we need to add some new
// properties
var clonedNestedTag = new Tag();
extend(clonedNestedTag, nestedTag);
// Record the fully qualified name of the parent tag that this
// custom tag is associated with.
clonedNestedTag.parentTagName = parentTagName;
clonedNestedTag.name = fullyQualifiedName;
merged.tags[fullyQualifiedName] = clonedNestedTag;
handleNestedTags(clonedNestedTag, fullyQualifiedName);
});
}
taglib.forEachTag(function(tag) {
tag.forEachNestedTag(function(nestedTag) {
handleNestedTag(nestedTag, tag.name);
});
handleNestedTags(tag, tag.name);
});
}

View File

@ -17,4 +17,4 @@
"required": true
}
}
}
}

View File

@ -0,0 +1 @@
<div>Foo: bar Body: <b>Deeply nested!</b></div><div>Foo: baz Body: <b>Another deeply nested!</b></div>

View 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>

View File

@ -0,0 +1 @@
exports.templateData = {};

View File

@ -0,0 +1,10 @@
{
"renderer": "./renderer",
"@class": "string",
"@items <item>[]": {
"@foo": "string",
"@body <body>": {
}
}
}

View File

@ -0,0 +1,5 @@
var template = require('./template.marko');
module.exports = function(input, out) {
template.render(input, out);
};

View 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>