Make the tag helper a static var

This commit is contained in:
Patrick Steele-Idem 2014-06-04 21:55:45 -06:00
parent 4a33eda751
commit fb8da02163

View File

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