Throw a handlebars exception when attempting to use template partials in VM mode.

This commit is contained in:
kpdecker
2011-07-30 16:01:43 -05:00
parent 8e23ce87d3
commit ccf32821df
2 changed files with 14 additions and 1 deletions
+3 -1
View File
@@ -71,8 +71,10 @@ Handlebars.VM = {
throw new Handlebars.Exception("The partial " + name + " could not be found");
} else if(partial instanceof Function) {
return partial(context, {helpers: helpers, partials: partials});
} else if (false && !Handlebars.compile) {
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in vm mode");
} else {
partials[name] = Handlebars.VM.compile(partial);
partials[name] = Handlebars.compile(partial);
return partials[name](context, {helpers: helpers, partials: partials});
}
}
+11
View File
@@ -410,6 +410,17 @@ test("rendering undefined partial throws an exception", function() {
}, Handlebars.Exception, "Should throw exception");
});
test("rendering template partial in vm mode throws an exception", function() {
shouldThrow(function() {
var template = CompilerContext.compile("{{> whatever}}");
var string = "Dudes: {{>dude}} {{another_dude}}";
var dude = "{{name}}";
var hash = {name:"Jeepers", another_dude:"Creepers"};
template();
}, Handlebars.Exception, "Should throw exception");
});
test("GH-14: a partial preceding a selector", function() {
var string = "Dudes: {{>dude}} {{another_dude}}";
var dude = "{{name}}";