Add a #with helper
This commit is contained in:
@@ -99,6 +99,10 @@ Handlebars.registerHelper('if', function(context, fn, inverse) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('with', function(context, fn) {
|
||||||
|
return fn(context);
|
||||||
|
});
|
||||||
|
|
||||||
Handlebars.logger = {
|
Handlebars.logger = {
|
||||||
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -486,4 +486,12 @@ test("if a context is not found, helperMissing is used", function() {
|
|||||||
var context = { hello: "Hello", world: "world" };
|
var context = { hello: "Hello", world: "world" };
|
||||||
|
|
||||||
shouldCompileTo(string, context, "Hello <a>world</a>")
|
shouldCompileTo(string, context, "Hello <a>world</a>")
|
||||||
})
|
});
|
||||||
|
|
||||||
|
module("built-in helpers");
|
||||||
|
|
||||||
|
test("with", function() {
|
||||||
|
var string = "{{#with person}}{{first}} {{last}}{{/with}}";
|
||||||
|
|
||||||
|
shouldCompileTo(string, {person: {first: "Alan", last: "Johnson"}}, "Alan Johnson");
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user