Restructure things more simply
This commit is contained in:
@@ -18,6 +18,3 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
rspec
|
rspec
|
||||||
therubyracer (>= 0.8.0.pre3)
|
therubyracer (>= 0.8.0.pre3)
|
||||||
|
|
||||||
METADATA
|
|
||||||
version: 1.1.pre
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ def remove_exports(string)
|
|||||||
match ? match[1] : string
|
match ? match[1] : string
|
||||||
end
|
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"
|
"lib/handlebars/#{file}.js"
|
||||||
end
|
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"
|
"lib/handlebars/#{file}.js"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+10
-12
@@ -1,18 +1,16 @@
|
|||||||
var Handlebars = require("handlebars/compiler").Handlebars;
|
var Handlebars = require("handlebars/base");
|
||||||
|
module.exports = Handlebars;
|
||||||
|
|
||||||
Handlebars.AST = require("handlebars/ast").AST;
|
require("handlebars/utils");
|
||||||
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
|
|
||||||
Handlebars.Runtime = require("handlebars/runtime").Runtime;
|
require("handlebars/ast");
|
||||||
Handlebars.Context = require("Handlebars/runtime").Context;
|
require("handlebars/printer");
|
||||||
Handlebars.Utils = require("handlebars/utils").Utils;
|
require("handlebars/visitor");
|
||||||
Handlebars.SafeString = require("handlebars/utils").SafeString;
|
|
||||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
require("handlebars/runtime");
|
||||||
Handlebars.Compiler = require("handlebars/vm").Compiler;
|
require("handlebars/vm");
|
||||||
Handlebars.JavaScriptCompiler = require("handlebars/vm").JavaScriptCompiler;
|
|
||||||
Handlebars.VM = require("handlebars/vm").VM;
|
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
|
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Handlebars = Handlebars;
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
var Handlebars = {};
|
var Handlebars = require("handlebars");
|
||||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
(function() {
|
(function() {
|
||||||
@@ -69,7 +68,7 @@ Handlebars.Exception = require("handlebars/utils").Exception;
|
|||||||
|
|
||||||
this.parts = dig;
|
this.parts = dig;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.isSimple = (dig.length === 1) && (depth === 0)
|
this.isSimple = (dig.length === 1) && (depth === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
Handlebars.AST.StringNode = function(string) {
|
Handlebars.AST.StringNode = function(string) {
|
||||||
@@ -85,4 +84,3 @@ Handlebars.Exception = require("handlebars/utils").Exception;
|
|||||||
})();
|
})();
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.AST = Handlebars.AST;
|
|
||||||
|
|||||||
@@ -18,15 +18,8 @@ Handlebars.compile = function(string) {
|
|||||||
var ast = Handlebars.parse(string);
|
var ast = Handlebars.parse(string);
|
||||||
|
|
||||||
return function(context, helpers, partials) {
|
return function(context, helpers, partials) {
|
||||||
var helpers, partials;
|
helpers = helpers || Handlebars.helpers;
|
||||||
|
partials = partials || Handlebars.partials;
|
||||||
if(!helpers) {
|
|
||||||
helpers = Handlebars.helpers;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!partials) {
|
|
||||||
partials = Handlebars.partials;
|
|
||||||
}
|
|
||||||
|
|
||||||
var internalContext = new Handlebars.Context(context, helpers, partials);
|
var internalContext = new Handlebars.Context(context, helpers, partials);
|
||||||
var runtime = new Handlebars.Runtime(internalContext);
|
var runtime = new Handlebars.Runtime(internalContext);
|
||||||
@@ -71,10 +64,10 @@ Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
return fn(context);
|
return fn(context);
|
||||||
}
|
}
|
||||||
}, function(context, fn) {
|
}, function(context, fn) {
|
||||||
return fn(context)
|
return fn(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
Handlebars.registerHelper('each', function(context, fn, inverse) {
|
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) {
|
Handlebars.registerHelper('with', function(context, fn) {
|
||||||
return fn(context);
|
return fn(context);
|
||||||
});
|
});
|
||||||
@@ -106,11 +103,11 @@ Handlebars.logger = {
|
|||||||
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
||||||
|
|
||||||
// override in the host environment
|
// override in the host environment
|
||||||
log: function(level, str) {},
|
log: function(level, str) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
||||||
|
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Handlebars = Handlebars;
|
module.exports = Handlebars;
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
var Handlebars = require("handlebars");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
(function() {
|
(function() {
|
||||||
var classes = ["Lexer", "PrintVisitor", "Context", "Runtime", "Exception"];
|
var classes = ["Lexer", "PrintVisitor", "Context", "Runtime", "Exception"];
|
||||||
var prop;
|
var prop;
|
||||||
@@ -23,3 +26,4 @@
|
|||||||
Handlebars.print.displayName = "Handlebars.print";
|
Handlebars.print.displayName = "Handlebars.print";
|
||||||
Handlebars.compile.displayName = "Handlebars.compile";
|
Handlebars.compile.displayName = "Handlebars.compile";
|
||||||
})();
|
})();
|
||||||
|
// END(BROWSER)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var Handlebars = {};
|
var Handlebars = require("handlebars");
|
||||||
Handlebars.Visitor = require("handlebars/visitor").Visitor;
|
require("handlebars/visitor");
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
Handlebars.PrintVisitor = function() { this.padding = 0; };
|
Handlebars.PrintVisitor = function() { this.padding = 0; };
|
||||||
|
|||||||
@@ -2,17 +2,7 @@ var inspect = function(obj) {
|
|||||||
require("sys").print(require("sys").inspect(obj) + "\n");
|
require("sys").print(require("sys").inspect(obj) + "\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
var Handlebars = {};
|
var Handlebars = require("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;
|
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
// A Context wraps data, and makes it possible to extract a
|
// A Context wraps data, and makes it possible to extract a
|
||||||
@@ -275,5 +265,3 @@ Handlebars.Runtime.prototype = {
|
|||||||
};
|
};
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Runtime = Handlebars.Runtime;
|
|
||||||
exports.Context = Handlebars.Context;
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var Handlebars = {};
|
var Handlebars = require("handlebars");
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
Handlebars.Exception = function(message) {
|
Handlebars.Exception = function(message) {
|
||||||
@@ -56,6 +56,3 @@ Handlebars.SafeString.prototype.toString = function() {
|
|||||||
})();
|
})();
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Utils = Handlebars.Utils;
|
|
||||||
exports.SafeString = Handlebars.SafeString;
|
|
||||||
exports.Exception = Handlebars.Exception;
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var Handlebars = {};
|
var Handlebars = require("handlebars");
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
|
|
||||||
@@ -11,4 +11,3 @@ Handlebars.Visitor.prototype = {
|
|||||||
};
|
};
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Visitor = Handlebars.Visitor;
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
var Handlebars = {};
|
var Handlebars = require("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;
|
|
||||||
|
|
||||||
// BEGIN(BROWSER)
|
// BEGIN(BROWSER)
|
||||||
Handlebars.Compiler = function() {};
|
Handlebars.Compiler = function() {};
|
||||||
@@ -629,6 +625,3 @@ Handlebars.VM = {
|
|||||||
};
|
};
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Compiler = Handlebars.Compiler;
|
|
||||||
exports.JavaScriptCompiler = Handlebars.JavaScriptCompiler;
|
|
||||||
exports.VM = Handlebars.VM;
|
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ module Handlebars
|
|||||||
end
|
end
|
||||||
|
|
||||||
Handlebars::Spec.js_load('lib/handlebars/parser.js')
|
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/ast.js');
|
||||||
Handlebars::Spec.js_load('lib/handlebars/visitor.js');
|
Handlebars::Spec.js_load('lib/handlebars/visitor.js');
|
||||||
Handlebars::Spec.js_load('lib/handlebars/printer.js')
|
Handlebars::Spec.js_load('lib/handlebars/printer.js')
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ describe "Tokenizer" do
|
|||||||
|
|
||||||
it "tokenizes inverse sections as 'OPEN_INVERSE CLOSE'" do
|
it "tokenizes inverse sections as 'OPEN_INVERSE CLOSE'" do
|
||||||
tokenize("{{^}}").should match_tokens(%w(OPEN_INVERSE CLOSE))
|
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
|
end
|
||||||
|
|
||||||
it "tokenizes inverse sections with ID as 'OPEN_INVERSE ID CLOSE'" do
|
it "tokenizes inverse sections with ID as 'OPEN_INVERSE ID CLOSE'" do
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<mu>"{{#" { return 'OPEN_BLOCK'; }
|
<mu>"{{#" { return 'OPEN_BLOCK'; }
|
||||||
<mu>"{{/" { return 'OPEN_ENDBLOCK'; }
|
<mu>"{{/" { return 'OPEN_ENDBLOCK'; }
|
||||||
<mu>"{{^" { return 'OPEN_INVERSE'; }
|
<mu>"{{^" { return 'OPEN_INVERSE'; }
|
||||||
|
<mu>"{{"\s*"else" { return 'OPEN_INVERSE'; }
|
||||||
<mu>"{{{" { return 'OPEN_UNESCAPED'; }
|
<mu>"{{{" { return 'OPEN_UNESCAPED'; }
|
||||||
<mu>"{{&" { return 'OPEN_UNESCAPED'; }
|
<mu>"{{&" { return 'OPEN_UNESCAPED'; }
|
||||||
<mu>"{{!".*?"}}" { yytext = yytext.substr(3,yyleng-5); this.begin("INITIAL"); return 'COMMENT'; }
|
<mu>"{{!".*?"}}" { yytext = yytext.substr(3,yyleng-5); this.begin("INITIAL"); return 'COMMENT'; }
|
||||||
|
|||||||
Reference in New Issue
Block a user