Files
handlebars.js/lib/handlebars/ast.js
T
wycats 762329913d Fix a number of outstanding issues:
* {{}} escape their contents, {{{}}} and {{& }} do not
* Add support in the parser, tokenizer and AST for partials
  with context (support is still not there in the runtime)
* Fix some inconsistencies with the old behavior involving
  the correct printing of null and undefined
* Add Handlebars.Exception
* Fixed an issue involving ./foo and this/foo
* Fleshed out helperMissing in the specs (this will be
  moved out into handlebars proper once registerHelper
  and registerPartial are added)
2010-12-02 01:13:24 -05:00

65 lines
1.3 KiB
JavaScript

if(exports) { var Handlebars = {} }
Handlebars.AST = {};
Handlebars.AST.ProgramNode = function(statements, inverse) {
this.type = "program";
this.statements = statements;
this.inverse = inverse;
};
Handlebars.AST.MustacheNode = function(params, unescaped) {
this.type = "mustache";
this.id = params[0];
this.params = params.slice(1);
this.escaped = !unescaped;
};
Handlebars.AST.PartialNode = function(id, context) {
this.type = "partial";
this.id = id;
this.context = context;
};
Handlebars.AST.BlockNode = function(mustache, program) {
this.type = "block";
this.mustache = mustache;
this.program = program;
};
Handlebars.AST.ContentNode = function(string) {
this.type = "content";
this.string = string;
}
Handlebars.AST.IdNode = function(parts) {
this.type = "ID"
var dig = [], depth = 0;
for(var i=0,l=parts.length; i<l; i++) {
var part = parts[i];
if(part === "..") { depth++; }
else if(part === "." || part === "this") { continue; }
else { dig.push(part) }
}
this.parts = dig;
this.depth = depth;
}
Handlebars.AST.StringNode = function(string) {
this.type = "STRING";
this.string = string;
}
Handlebars.AST.CommentNode = function(comment) {
this.type = "comment";
this.comment = comment;
}
if(exports) {
exports.AST = Handlebars.AST;
}