Avoid direct references to sexpr in statements
This allows us to avoid creating unnecessary AST nodes and avoids things like isHelper. Side effect of these changes is that @data functions can now have data parameters passed to them.
This commit is contained in:
+7
-8
@@ -24,11 +24,10 @@ describe('Visitor', function() {
|
||||
visitor.BooleanLiteral = function(bool) {
|
||||
equal(bool.value, true);
|
||||
|
||||
equal(this.parents.length, 4);
|
||||
equal(this.parents.length, 3);
|
||||
equal(this.parents[0].type, 'SubExpression');
|
||||
equal(this.parents[1].type, 'SubExpression');
|
||||
equal(this.parents[2].type, 'BlockStatement');
|
||||
equal(this.parents[3].type, 'Program');
|
||||
equal(this.parents[1].type, 'BlockStatement');
|
||||
equal(this.parents[2].type, 'Program');
|
||||
};
|
||||
visitor.PathExpression = function(id) {
|
||||
equal(/(foo\.)?bar$/.test(id.original), true);
|
||||
@@ -84,26 +83,26 @@ describe('Visitor', function() {
|
||||
var visitor = new Handlebars.Visitor();
|
||||
|
||||
visitor.mutating = true;
|
||||
visitor.SubExpression = function() {
|
||||
visitor.PathExpression = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
var ast = Handlebars.parse('{{foo 42}}');
|
||||
visitor.accept(ast);
|
||||
}, Handlebars.Exception, 'MustacheStatement requires sexpr');
|
||||
}, Handlebars.Exception, 'MustacheStatement requires path');
|
||||
});
|
||||
it('should throw when returning non-node responses', function() {
|
||||
shouldThrow(function() {
|
||||
var visitor = new Handlebars.Visitor();
|
||||
|
||||
visitor.mutating = true;
|
||||
visitor.SubExpression = function() {
|
||||
visitor.PathExpression = function() {
|
||||
return {};
|
||||
};
|
||||
|
||||
var ast = Handlebars.parse('{{foo 42}}');
|
||||
visitor.accept(ast);
|
||||
}, Handlebars.Exception, 'Unexpected node type "undefined" found when accepting sexpr on MustacheStatement');
|
||||
}, Handlebars.Exception, 'Unexpected node type "undefined" found when accepting path on MustacheStatement');
|
||||
});
|
||||
});
|
||||
describe('arrays', function() {
|
||||
|
||||
Reference in New Issue
Block a user