Fixed bug where compiler was continuing to think it was looking at partials after the partial tag was done. Closes GH-14.
This commit is contained in:
@@ -462,9 +462,11 @@ Handlebars.Compiler.prototype = {
|
||||
return;
|
||||
} else if (this.partial) {
|
||||
this.addPartial(mustache, param)
|
||||
this.partial = false;
|
||||
return;
|
||||
} else if (this.inverted) {
|
||||
this.addInvertedSection(mustache);
|
||||
this.inverted = false;
|
||||
return;
|
||||
} else if(this.openBlock) {
|
||||
this.addBlock(mustache, param, parts)
|
||||
|
||||
+9
-2
@@ -325,7 +325,7 @@ test("basic partials", function() {
|
||||
});
|
||||
|
||||
test("partials with context", function() {
|
||||
var string = "Dudes: {{> dude dudes}}";
|
||||
var string = "Dudes: {{>dude dudes}}";
|
||||
var partial = "{{#this}}{{name}} ({{url}}) {{/this}}";
|
||||
var hash = {dudes: [{name: "Yehuda", url: "http://yehuda"}, {name: "Alan", url: "http://alan"}]};
|
||||
shouldCompileTo(string, [hash, {partials: {dude: partial}}], "Dudes: Yehuda (http://yehuda) Alan (http://alan) ",
|
||||
@@ -333,7 +333,7 @@ test("partials with context", function() {
|
||||
});
|
||||
|
||||
test("partial in a partial", function() {
|
||||
var string = "Dudes: {{#dudes}}{{> dude}}{{/dudes}}";
|
||||
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"}]};
|
||||
@@ -347,6 +347,13 @@ test("rendering undefined partial throws an exception", function() {
|
||||
}, Handlebars.Exception, "Should throw exception");
|
||||
});
|
||||
|
||||
test("GH-14: a partial preceding a selector", function() {
|
||||
var string = "Dudes: {{>dude}} {{another_dude}}";
|
||||
var dude = "{{name}}";
|
||||
var hash = {name:"Jeepers", another_dude:"Creepers"};
|
||||
shouldCompileTo(string, [hash, {partials: {dude:dude}}], "Dudes: Jeepers Creepers", "Regular selectors can follow a partial");
|
||||
});
|
||||
|
||||
module("safestring");
|
||||
|
||||
test("constructing a safestring from a string and checking its type", function() {
|
||||
|
||||
Reference in New Issue
Block a user