Added test for a partial inside of a partial.

This commit is contained in:
Alan Johnson
2010-08-12 22:46:20 -04:00
parent ab757858a2
commit 57aadef7c1
2 changed files with 10 additions and 0 deletions
+2
View File
@@ -2,6 +2,8 @@ Handlebars = {
compile: function(string) {
var compiler = new Handlebars.Compiler(string);
var result = compiler.compile();
console.log("Template: " + string);
console.log("Code: " + result);
return new Function("context", "fallback", "fallback = fallback || {}; var stack = [];var partials = {};" + result);
},
+8
View File
@@ -198,6 +198,14 @@ test("partials with context", function() {
"Partials can be passed a context");
});
test("partial in a partial", function() {
var string = "Dudes: {{#dudes}}{{> dude}}{{/dudes}}";
var dude = "{{name}} {{> url}} ";
var url = "<a href={{url}}>{{url}}</a>";
var hash = {dudes: [{name: "Yehuda", url: "http://yehuda"}, {name: "Alan", url: "http://alan"}]};
shouldCompileTo(string, [hash, {partials: {dude: dude, url: url}}], "Dudes: Yehuda <a href=http://yehuda>http://yehuda</a> Alan <a href=http://alan>http://alan</a> ", "Partials are rendered inside of other partials");
});
module("safestring");
test("constructing a safestring from a string and checking its type", function() {