summaryrefslogtreecommitdiffstats
path: root/spec/partials.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/partials.js')
-rw-r--r--spec/partials.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/spec/partials.js b/spec/partials.js
index 20187f8..c5b8fdc 100644
--- a/spec/partials.js
+++ b/spec/partials.js
@@ -41,11 +41,18 @@ describe('partials', function() {
it("rendering undefined partial throws an exception", function() {
shouldThrow(function() {
- var template = CompilerContext.compile("{{> whatever}}");
- template();
+ var template = CompilerContext.compile("{{> whatever}}");
+ template();
}, Handlebars.Exception, 'The partial whatever could not be found');
});
+ it("registering undefined partial throws an exception", function() {
+ shouldThrow(function() {
+ var undef;
+ handlebarsEnv.registerPartial('undefined_test', undef);
+ }, Handlebars.Exception, 'Attempting to register a partial as undefined');
+ });
+
it("rendering template partial in vm mode throws an exception", function() {
shouldThrow(function() {
var template = CompilerContext.compile("{{> whatever}}");
@@ -64,10 +71,10 @@ describe('partials', function() {
});
it("GH-14: a partial preceding a selector", function() {
- var string = "Dudes: {{>dude}} {{another_dude}}";
- var dude = "{{name}}";
- var hash = {name:"Jeepers", another_dude:"Creepers"};
- shouldCompileToWithPartials(string, [hash, {}, {dude:dude}], true, "Dudes: Jeepers Creepers", "Regular selectors can follow a partial");
+ var string = "Dudes: {{>dude}} {{another_dude}}";
+ var dude = "{{name}}";
+ var hash = {name:"Jeepers", another_dude:"Creepers"};
+ shouldCompileToWithPartials(string, [hash, {}, {dude:dude}], true, "Dudes: Jeepers Creepers", "Regular selectors can follow a partial");
});
it("Partials with slash paths", function() {
@@ -167,6 +174,14 @@ describe('partials', function() {
shouldCompileToWithPartials(string, [hash, {}, {dude: dude, url: url}], true,
"Dudes:\n Yehuda\n http://yehuda!\n Alan\n http://alan!\n");
});
+ it("prevent nested indented partials", function() {
+ var string = "Dudes:\n{{#dudes}}\n {{>dude}}\n{{/dudes}}";
+ var dude = "{{name}}\n {{> url}}";
+ var url = "{{url}}!\n";
+ var hash = {dudes: [{name: "Yehuda", url: "http://yehuda"}, {name: "Alan", url: "http://alan"}]};
+ shouldCompileToWithPartials(string, [hash, {}, {dude: dude, url: url}, {preventIndent: true}], true,
+ "Dudes:\n Yehuda\n http://yehuda!\n Alan\n http://alan!\n");
+ });
});
describe('compat mode', function() {