Restructure things more simply

This commit is contained in:
wycats
2010-12-29 18:21:43 -08:00
parent 9e77799e87
commit bf6c74aa83
14 changed files with 39 additions and 65 deletions
+2 -4
View File
@@ -1,5 +1,4 @@
var Handlebars = {};
Handlebars.Exception = require("handlebars/utils").Exception;
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
(function() {
@@ -69,7 +68,7 @@ Handlebars.Exception = require("handlebars/utils").Exception;
this.parts = dig;
this.depth = depth;
this.isSimple = (dig.length === 1) && (depth === 0)
this.isSimple = (dig.length === 1) && (depth === 0);
};
Handlebars.AST.StringNode = function(string) {
@@ -85,4 +84,3 @@ Handlebars.Exception = require("handlebars/utils").Exception;
})();
// END(BROWSER)
exports.AST = Handlebars.AST;
@@ -18,15 +18,8 @@ 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;
}
helpers = helpers || Handlebars.helpers;
partials = partials || Handlebars.partials;
var internalContext = new Handlebars.Context(context, helpers, partials);
var runtime = new Handlebars.Runtime(internalContext);
@@ -71,10 +64,10 @@ Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
}
return ret;
} else {
return fn(context);
}
return fn(context);
}
}, function(context, fn) {
return fn(context)
return fn(context);
});
Handlebars.registerHelper('each', function(context, fn, inverse) {
@@ -98,6 +91,10 @@ Handlebars.registerHelper('if', function(context, fn, inverse) {
}
});
Handlebars.registerHelper('unless', function(context, fn, inverse) {
Handlebars.helpers['if'].call(this, context, inverse, fn);
});
Handlebars.registerHelper('with', function(context, fn) {
return fn(context);
});
@@ -106,11 +103,11 @@ Handlebars.logger = {
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
// override in the host environment
log: function(level, str) {},
log: function(level, str) {}
}
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
// END(BROWSER)
exports.Handlebars = Handlebars;
module.exports = Handlebars;
+4
View File
@@ -1,3 +1,6 @@
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
(function() {
var classes = ["Lexer", "PrintVisitor", "Context", "Runtime", "Exception"];
var prop;
@@ -23,3 +26,4 @@
Handlebars.print.displayName = "Handlebars.print";
Handlebars.compile.displayName = "Handlebars.compile";
})();
// END(BROWSER)
+2 -2
View File
@@ -1,5 +1,5 @@
var Handlebars = {};
Handlebars.Visitor = require("handlebars/visitor").Visitor;
var Handlebars = require("handlebars");
require("handlebars/visitor");
// BEGIN(BROWSER)
Handlebars.PrintVisitor = function() { this.padding = 0; };
+1 -13
View File
@@ -2,17 +2,7 @@ var inspect = function(obj) {
require("sys").print(require("sys").inspect(obj) + "\n");
};
var Handlebars = {};
Handlebars.AST = require("handlebars/ast").AST;
Handlebars.Visitor = require("handlebars/visitor").Visitor;
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;
Handlebars.parse = require("handlebars/compiler").Handlebars.parse;
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
// A Context wraps data, and makes it possible to extract a
@@ -275,5 +265,3 @@ Handlebars.Runtime.prototype = {
};
// END(BROWSER)
exports.Runtime = Handlebars.Runtime;
exports.Context = Handlebars.Context;
+1 -4
View File
@@ -1,4 +1,4 @@
var Handlebars = {};
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
Handlebars.Exception = function(message) {
@@ -56,6 +56,3 @@ Handlebars.SafeString.prototype.toString = function() {
})();
// END(BROWSER)
exports.Utils = Handlebars.Utils;
exports.SafeString = Handlebars.SafeString;
exports.Exception = Handlebars.Exception;
+1 -2
View File
@@ -1,4 +1,4 @@
var Handlebars = {};
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
@@ -11,4 +11,3 @@ Handlebars.Visitor.prototype = {
};
// END(BROWSER)
exports.Visitor = Handlebars.Visitor;
+1 -8
View File
@@ -1,8 +1,4 @@
var Handlebars = {};
Handlebars.Utils = require("handlebars/utils").Utils;
Handlebars.parse = require("handlebars/compiler").Handlebars.parse;
Handlebars.logger = require("handlebars/compiler").Handlebars.logger;
Handlebars.log = require("handlebars/compiler").Handlebars.log;
var Handlebars = require("handlebars");
// BEGIN(BROWSER)
Handlebars.Compiler = function() {};
@@ -629,6 +625,3 @@ Handlebars.VM = {
};
// END(BROWSER)
exports.Compiler = Handlebars.Compiler;
exports.JavaScriptCompiler = Handlebars.JavaScriptCompiler;
exports.VM = Handlebars.VM;