Added 'log' helper - See #97
This commit is contained in:
@@ -86,6 +86,10 @@ Handlebars.registerHelper('with', function(context, options) {
|
||||
return options.fn(context);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('log', function(context) {
|
||||
Handlebars.log(context);
|
||||
});
|
||||
|
||||
// END(BROWSER)
|
||||
|
||||
module.exports = Handlebars;
|
||||
|
||||
@@ -104,7 +104,8 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
'each': true,
|
||||
'if': true,
|
||||
'unless': true,
|
||||
'with': true
|
||||
'with': true,
|
||||
'log': true
|
||||
};
|
||||
if (knownHelpers) {
|
||||
for (var name in knownHelpers) {
|
||||
|
||||
+18
-1
@@ -576,7 +576,11 @@ test("Invert blocks work in knownHelpers only mode", function() {
|
||||
equal(result, "bar", "'bar' should === '" + result);
|
||||
});
|
||||
|
||||
module("built-in helpers");
|
||||
var teardown;
|
||||
module("built-in helpers", {
|
||||
setup: function(){ teardown = null; },
|
||||
teardown: function(){ if (teardown) { teardown(); } }
|
||||
});
|
||||
|
||||
test("with", function() {
|
||||
var string = "{{#with person}}{{first}} {{last}}{{/with}}";
|
||||
@@ -608,6 +612,19 @@ test("each", function() {
|
||||
"each with array argument ignores the contents when empty");
|
||||
});
|
||||
|
||||
test("log", function() {
|
||||
var string = "{{log blah}}"
|
||||
var hash = { blah: "whee" };
|
||||
|
||||
var logArg;
|
||||
var originalLog = Handlebars.log;
|
||||
Handlebars.log = function(arg){ logArg = arg; }
|
||||
teardown = function(){ Handlebars.log = originalLog; }
|
||||
|
||||
shouldCompileTo(string, hash, "", "log should not display");
|
||||
equals("whee", logArg, "should call log with 'whee'");
|
||||
});
|
||||
|
||||
test("overriding property lookup", function() {
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user