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.inputExpression = null;
|
||||
}
|
||||
TagHandlerNode.nodeType = 'element';
|
||||
|
||||
TagHandlerNode.convertNode = function (node, tag) {
|
||||
extend(node, TagHandlerNode.prototype);
|
||||
TagHandlerNode.call(node, tag);
|
||||
};
|
||||
|
||||
TagHandlerNode.prototype = {
|
||||
addDynamicAttribute: function (name, value) {
|
||||
if (!this.dynamicAttributes) {
|
||||
@ -85,6 +88,7 @@ TagHandlerNode.prototype = {
|
||||
doGenerateCode: function (template) {
|
||||
var rendererPath = raptorModulesResolver.deresolve(this.tag.renderer, template.dirname);
|
||||
var handlerVar = addHandlerVar(template, rendererPath);
|
||||
var tagHelperVar = template.addStaticVar('_tag', '__helpers.t');
|
||||
|
||||
this.tag.forEachImportedVariable(function (importedVariable) {
|
||||
this.setProperty(importedVariable.targetProperty, template.makeExpression(importedVariable.expression));
|
||||
@ -126,8 +130,8 @@ TagHandlerNode.prototype = {
|
||||
variableNames.push(varName);
|
||||
}, this);
|
||||
|
||||
template.contextHelperMethodCall('t', function () {
|
||||
template.code('\n').indent(function () {
|
||||
template.functionCall(tagHelperVar, function () {
|
||||
template.code('context,\n').indent(function () {
|
||||
template.line(handlerVar + ',').indent();
|
||||
if (_this.inputExpression) {
|
||||
template.code(_this.inputExpression);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user