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
-3
View File
@@ -18,6 +18,3 @@ PLATFORMS
DEPENDENCIES
rspec
therubyracer (>= 0.8.0.pre3)
METADATA
version: 1.1.pre
+2 -2
View File
@@ -20,11 +20,11 @@ def remove_exports(string)
match ? match[1] : string
end
minimal_deps = %w(parser compiler ast visitor runtime utils vm).map do |file|
minimal_deps = %w(parser base ast visitor runtime utils vm).map do |file|
"lib/handlebars/#{file}.js"
end
debug_deps = %w(parser compiler ast visitor printer runtime utils vm).map do |file|
debug_deps = %w(parser base ast visitor printer runtime utils vm).map do |file|
"lib/handlebars/#{file}.js"
end
+10 -12
View File
@@ -1,18 +1,16 @@
var Handlebars = require("handlebars/compiler").Handlebars;
var Handlebars = require("handlebars/base");
module.exports = Handlebars;
Handlebars.AST = require("handlebars/ast").AST;
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
Handlebars.Runtime = require("handlebars/runtime").Runtime;
Handlebars.Context = require("Handlebars/runtime").Context;
Handlebars.Utils = require("handlebars/utils").Utils;
Handlebars.SafeString = require("handlebars/utils").SafeString;
Handlebars.Exception = require("handlebars/utils").Exception;
Handlebars.Compiler = require("handlebars/vm").Compiler;
Handlebars.JavaScriptCompiler = require("handlebars/vm").JavaScriptCompiler;
Handlebars.VM = require("handlebars/vm").VM;
require("handlebars/utils");
require("handlebars/ast");
require("handlebars/printer");
require("handlebars/visitor");
require("handlebars/runtime");
require("handlebars/vm");
// BEGIN(BROWSER)
// END(BROWSER)
exports.Handlebars = Handlebars;
+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);
@@ -74,7 +67,7 @@ Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
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;
+1 -1
View File
@@ -73,7 +73,7 @@ module Handlebars
end
Handlebars::Spec.js_load('lib/handlebars/parser.js')
Handlebars::Spec.js_load('lib/handlebars/compiler.js');
Handlebars::Spec.js_load('lib/handlebars/base.js');
Handlebars::Spec.js_load('lib/handlebars/ast.js');
Handlebars::Spec.js_load('lib/handlebars/visitor.js');
Handlebars::Spec.js_load('lib/handlebars/printer.js')
+2
View File
@@ -95,6 +95,8 @@ describe "Tokenizer" do
it "tokenizes inverse sections as 'OPEN_INVERSE CLOSE'" do
tokenize("{{^}}").should match_tokens(%w(OPEN_INVERSE CLOSE))
tokenize("{{else}}").should match_tokens(%w(OPEN_INVERSE CLOSE))
tokenize("{{ else }}").should match_tokens(%w(OPEN_INVERSE CLOSE))
end
it "tokenizes inverse sections with ID as 'OPEN_INVERSE ID CLOSE'" do
+1
View File
@@ -10,6 +10,7 @@
<mu>"{{#" { return 'OPEN_BLOCK'; }
<mu>"{{/" { return 'OPEN_ENDBLOCK'; }
<mu>"{{^" { return 'OPEN_INVERSE'; }
<mu>"{{"\s*"else" { return 'OPEN_INVERSE'; }
<mu>"{{{" { return 'OPEN_UNESCAPED'; }
<mu>"{{&" { return 'OPEN_UNESCAPED'; }
<mu>"{{!".*?"}}" { yytext = yytext.substr(3,yyleng-5); this.begin("INITIAL"); return 'COMMENT'; }