Files
handlebars.js/lib/handlebars.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

36 lines
1.2 KiB
JavaScript

if(exports) {
var Handlebars = {};
Handlebars.AST = require("handlebars/ast").AST;
Handlebars.HandlebarsLexer = require("handlebars/handlebars_lexer").Lexer;
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
Handlebars.Parser = require("handlebars/parser").parser;
Handlebars.Runtime = require("handlebars/runtime").Runtime;
Handlebars.Utils = require("handlebars/utils").Utils;
Handlebars.SafeString = require("handlebars/utils").SafeString;
Handlebars.Exception = require("handlebars/utils").Exception;
} else {
Handlebars.Parser = handlebars;
}
Handlebars.parse = function(string) {
Handlebars.Parser.yy = Handlebars.AST;
Handlebars.Parser.lexer = new Handlebars.HandlebarsLexer;
return Handlebars.Parser.parse(string);
};
Handlebars.print = function(ast) {
return new Handlebars.PrintVisitor().accept(ast);
}
Handlebars.compile = function(string) {
var ast = Handlebars.parse(string);
return function(context, fallback) {
var runtime = new Handlebars.Runtime(context, fallback);
return runtime.accept(ast);
}
}
if(exports) { exports.Handlebars = Handlebars }