mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #51 Allow body content to be mapped to a String input property
This commit is contained in:
parent
0a980c9279
commit
b7fc101663
@ -215,6 +215,9 @@ Taglib.Tag = makeClass({
|
||||
name: name,
|
||||
params: params
|
||||
};
|
||||
},
|
||||
setBodyProperty: function(propertyName) {
|
||||
this.bodyProperty = propertyName;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user