mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Make the tag helper a static var
This commit is contained in:
parent
4a33eda751
commit
fb8da02163
@ -65,10 +65,13 @@ function TagHandlerNode(tag) {
|
|||||||
this.dynamicAttributes = null;
|
this.dynamicAttributes = null;
|
||||||
this.inputExpression = null;
|
this.inputExpression = null;
|
||||||
}
|
}
|
||||||
|
TagHandlerNode.nodeType = 'element';
|
||||||
|
|
||||||
TagHandlerNode.convertNode = function (node, tag) {
|
TagHandlerNode.convertNode = function (node, tag) {
|
||||||
extend(node, TagHandlerNode.prototype);
|
extend(node, TagHandlerNode.prototype);
|
||||||
TagHandlerNode.call(node, tag);
|
TagHandlerNode.call(node, tag);
|
||||||
};
|
};
|
||||||
|
|
||||||
TagHandlerNode.prototype = {
|
TagHandlerNode.prototype = {
|
||||||
addDynamicAttribute: function (name, value) {
|
addDynamicAttribute: function (name, value) {
|
||||||
if (!this.dynamicAttributes) {
|
if (!this.dynamicAttributes) {
|
||||||
@ -85,6 +88,7 @@ TagHandlerNode.prototype = {
|
|||||||
doGenerateCode: function (template) {
|
doGenerateCode: function (template) {
|
||||||
var rendererPath = raptorModulesResolver.deresolve(this.tag.renderer, template.dirname);
|
var rendererPath = raptorModulesResolver.deresolve(this.tag.renderer, template.dirname);
|
||||||
var handlerVar = addHandlerVar(template, rendererPath);
|
var handlerVar = addHandlerVar(template, rendererPath);
|
||||||
|
var tagHelperVar = template.addStaticVar('_tag', '__helpers.t');
|
||||||
|
|
||||||
this.tag.forEachImportedVariable(function (importedVariable) {
|
this.tag.forEachImportedVariable(function (importedVariable) {
|
||||||
this.setProperty(importedVariable.targetProperty, template.makeExpression(importedVariable.expression));
|
this.setProperty(importedVariable.targetProperty, template.makeExpression(importedVariable.expression));
|
||||||
@ -126,8 +130,8 @@ TagHandlerNode.prototype = {
|
|||||||
variableNames.push(varName);
|
variableNames.push(varName);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
template.contextHelperMethodCall('t', function () {
|
template.functionCall(tagHelperVar, function () {
|
||||||
template.code('\n').indent(function () {
|
template.code('context,\n').indent(function () {
|
||||||
template.line(handlerVar + ',').indent();
|
template.line(handlerVar + ',').indent();
|
||||||
if (_this.inputExpression) {
|
if (_this.inputExpression) {
|
||||||
template.code(_this.inputExpression);
|
template.code(_this.inputExpression);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user