summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler.js
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-12-29 18:21:43 -0800
committerwycats <wycats@gmail.com>2010-12-29 18:21:43 -0800
commitbf6c74aa83e6ce32da30b1602bcafc025306ba4d (patch)
treeda3788539e0f8168140542d58f6977eef5e706c2 /lib/handlebars/compiler.js
parent9e77799e87fbb85dcc6f6f19ebc57f9dcdfdcb6a (diff)
downloadhandlebars.js-bf6c74aa83e6ce32da30b1602bcafc025306ba4d.zip
handlebars.js-bf6c74aa83e6ce32da30b1602bcafc025306ba4d.tar.gz
handlebars.js-bf6c74aa83e6ce32da30b1602bcafc025306ba4d.tar.bz2
Restructure things more simply
Diffstat (limited to 'lib/handlebars/compiler.js')
-rw-r--r--lib/handlebars/compiler.js116
1 files changed, 0 insertions, 116 deletions
diff --git a/lib/handlebars/compiler.js b/lib/handlebars/compiler.js
deleted file mode 100644
index d1e4445..0000000
--- a/lib/handlebars/compiler.js
+++ /dev/null
@@ -1,116 +0,0 @@
-var handlebars = require("handlebars/parser").parser;
-
-// BEGIN(BROWSER)
-var Handlebars = {};
-
-Handlebars.Parser = handlebars;
-
-Handlebars.parse = function(string) {
- Handlebars.Parser.yy = Handlebars.AST;
- 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, helpers, partials) {
- var helpers, partials;
-
- if(!helpers) {
- helpers = Handlebars.helpers;
- }
-
- if(!partials) {
- partials = Handlebars.partials;
- }
-
- var internalContext = new Handlebars.Context(context, helpers, partials);
- var runtime = new Handlebars.Runtime(internalContext);
- runtime.accept(ast);
- return runtime.buffer;
- };
-};
-
-Handlebars.helpers = {};
-Handlebars.partials = {};
-
-Handlebars.registerHelper = function(name, fn, inverse) {
- if(inverse) { fn.not = inverse; }
- this.helpers[name] = fn;
-};
-
-Handlebars.registerPartial = function(name, str) {
- this.partials[name] = str;
-};
-
-Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
- inverse = inverse || function() {};
-
- var ret = "";
- var type = Object.prototype.toString.call(context);
-
- if(type === "[object Function]") {
- context = context();
- }
-
- if(context === true) {
- return fn(this);
- } else if(context === false || context == null) {
- return inverse(this);
- } else if(type === "[object Array]") {
- if(context.length > 0) {
- for(var i=0, j=context.length; i<j; i++) {
- ret = ret + fn(context[i]);
- }
- } else {
- ret = inverse(this);
- }
- return ret;
- } else {
- return fn(context);
- }
-}, function(context, fn) {
- return fn(context)
-});
-
-Handlebars.registerHelper('each', function(context, fn, inverse) {
- var ret = "";
-
- if(context && context.length > 0) {
- for(var i=0, j=context.length; i<j; i++) {
- ret = ret + fn(context[i]);
- }
- } else {
- ret = inverse(this);
- }
- return ret;
-});
-
-Handlebars.registerHelper('if', function(context, fn, inverse) {
- if(!context || context === []) {
- return inverse(this);
- } else {
- return fn(this);
- }
-});
-
-Handlebars.registerHelper('with', function(context, fn) {
- return fn(context);
-});
-
-Handlebars.logger = {
- DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
-
- // override in the host environment
- log: function(level, str) {},
-}
-
-Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
-
-// END(BROWSER)
-
-exports.Handlebars = Handlebars;