diff --git a/compiler/taglibs/Taglib.js b/compiler/taglibs/Taglib.js index bdb3da7ce..c31b4a28a 100644 --- a/compiler/taglibs/Taglib.js +++ b/compiler/taglibs/Taglib.js @@ -215,6 +215,9 @@ Taglib.Tag = makeClass({ name: name, params: params }; + }, + setBodyProperty: function(propertyName) { + this.bodyProperty = propertyName; } }); diff --git a/compiler/taglibs/taglib-loader.js b/compiler/taglibs/taglib-loader.js index bdd79ad34..d9d55c78e 100644 --- a/compiler/taglibs/taglib-loader.js +++ b/compiler/taglibs/taglib-loader.js @@ -217,6 +217,9 @@ function buildTag(tagObject, path, taglib, dirname) { tag.setBodyFunction(functionName, params); }, + bodyProperty: function(value) { + tag.setBodyProperty(value) + }, vars: function(value) { if (value) { value.forEach(function(v, i) { diff --git a/taglibs/core/TagHandlerNode.js b/taglibs/core/TagHandlerNode.js index 0442ab103..4096e29de 100644 --- a/taglibs/core/TagHandlerNode.js +++ b/taglibs/core/TagHandlerNode.js @@ -114,19 +114,27 @@ TagHandlerNode.prototype = { var handlerVar = addHandlerVar(template, rendererPath); var tagHelperVar = template.addStaticVar('__tag', '__helpers.t'); var bodyFunction = this.tag.bodyFunction; + var bodyProperty = this.tag.bodyProperty; this.tag.forEachImportedVariable(function (importedVariable) { this.setProperty(importedVariable.targetProperty, template.makeExpression(importedVariable.expression)); }, this); - if (bodyFunction && this.hasChildren()) { - this.setProperty(bodyFunction.name, function(template) { - template.code('function(' + bodyFunction.params + ') {\n').indent(function () { - _this.generateCodeForChildren(template); - }).indent().code('}'); - }); + if (this.hasChildren()) { + if (bodyFunction) { + this.setProperty(bodyFunction.name, function(template) { + template.code('function(' + bodyFunction.params + ') {\n').indent(function () { + _this.generateCodeForChildren(template); + }).indent().code('}'); + }); + } else if (bodyProperty) { + this.setProperty(bodyProperty, function(template) { + return _this.getBodyContentExpression(template); + }); + } } + var variableNames = []; _this.tag.forEachVariable(function (nestedVar) { var varName;