Fixes #51 Allow body content to be mapped to a String input property

This commit is contained in:
Patrick Steele-Idem 2015-03-20 13:01:04 -06:00
parent 0a980c9279
commit b7fc101663
3 changed files with 20 additions and 6 deletions

View File

@ -215,6 +215,9 @@ Taglib.Tag = makeClass({
name: name,
params: params
};
},
setBodyProperty: function(propertyName) {
this.bodyProperty = propertyName;
}
});

View File

@ -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) {

View File

@ -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;