diff options
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | lib/handlebars/base.js | 22 | ||||
-rw-r--r-- | lib/handlebars/compiler/base.js | 29 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 |
4 files changed, 32 insertions, 24 deletions
@@ -28,7 +28,7 @@ def remove_exports(string) match ? match[1] : string end -minimal_deps = %w(compiler/parser base compiler/ast utils compiler/compiler vm).map do |file| +minimal_deps = %w(base compiler/parser compiler/base compiler/ast utils compiler/compiler vm).map do |file| "lib/handlebars/#{file}.js" end diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 76dd77a..c51dafb 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -1,21 +1,8 @@ -var handlebars = require("handlebars/compiler/parser").parser; - // BEGIN(BROWSER) var Handlebars = {}; Handlebars.VERSION = "1.0.beta.2"; -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.helpers = {}; Handlebars.partials = {}; @@ -99,15 +86,6 @@ Handlebars.registerHelper('with', function(context, options) { return options.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) module.exports = Handlebars; diff --git a/lib/handlebars/compiler/base.js b/lib/handlebars/compiler/base.js new file mode 100644 index 0000000..db1d3b4 --- /dev/null +++ b/lib/handlebars/compiler/base.js @@ -0,0 +1,29 @@ +var handlebars = require("handlebars/compiler/parser").parser; +var Handlebars = require("../base"); + +// BEGIN(BROWSER) +var Handlebars = 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.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) + +module.exports = Handlebars; diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 41f06ae..e71673a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -72,8 +72,9 @@ module Handlebars puts end - Handlebars::Spec.js_load('lib/handlebars/compiler/parser.js') Handlebars::Spec.js_load('lib/handlebars/base.js'); + Handlebars::Spec.js_load('lib/handlebars/compiler/parser.js') + Handlebars::Spec.js_load('lib/handlebars/compiler/base.js'); Handlebars::Spec.js_load('lib/handlebars/compiler/ast.js'); Handlebars::Spec.js_load('lib/handlebars/compiler/visitor.js'); Handlebars::Spec.js_load('lib/handlebars/compiler/printer.js') |