| @@ -1,7 +1,7 @@ | |||||
| {{#show_following}} | |||||
| {{/show_following}} | |||||
| {{#show_following}} | |||||
| {{/show_following}} | |||||
| {{#foo}} | |||||
| BAR | |||||
| {{/foo}} | |||||
| BAR | |||||
| {{^bar}} | |||||
| BAR | |||||
| {{/bar}} | |||||
| @@ -1 +1,4 @@ | |||||
| var two_sections = {}; | |||||
| var two_sections = { | |||||
| foo: true, | |||||
| bar: false | |||||
| }; | |||||
| @@ -1,3 +1,3 @@ | |||||
| BAR bar | |||||
| BAR bar | |||||
| BAR bar | |||||
| BAR | |||||
| BAR | |||||
| BAR | |||||
| @@ -149,7 +149,7 @@ var Mustache = function() { | |||||
| var that = this; | var that = this; | ||||
| var regex = new RegExp("(?:^([\\s\\S]*?))?" + this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag + | var regex = new RegExp("(?:^([\\s\\S]*?))?" + this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag + | ||||
| "\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\3\\s*" + this.ctag + "\\s*" + | |||||
| "\n*([\\s\\S]*?)" + this.otag + "\\/\\s*\\3\\s*" + this.ctag + "\\s*" + | |||||
| "([\\s\\S]*?)(?=(?:" + this.otag + "(?:\\^|\\#)\\s*(?:.+)\\s*" + this.ctag + ")|$)", "g"); | "([\\s\\S]*?)(?=(?:" + this.otag + "(?:\\^|\\#)\\s*(?:.+)\\s*" + this.ctag + ")|$)", "g"); | ||||
| // for each {{#foo}}{{/foo}} section do... | // for each {{#foo}}{{/foo}} section do... | ||||
| @@ -92,22 +92,18 @@ describe "mustache" do | |||||
| run_js(js).strip.should == "foo BAR" | run_js(js).strip.should == "foo BAR" | ||||
| end | end | ||||
| it "should not suck" do | |||||
| it "should work with empty sections" do | |||||
| js = <<-JS | js = <<-JS | ||||
| try{ | try{ | ||||
| #{@boilerplate} | #{@boilerplate} | ||||
| print(Mustache.to_html("{{#foo}}\\ | |||||
| {{/foo}}\\ | |||||
| {{#bar}}\\ | |||||
| {{/bar}}\\ | |||||
| ", {})); | |||||
| print(Mustache.to_html("{{#foo}}{{/foo}}foo{{#bar}}{{/bar}}", {})); | |||||
| } catch(e) { | } catch(e) { | ||||
| print(e); | print(e); | ||||
| } | } | ||||
| JS | JS | ||||
| run_js(js).should == "foanfs" | |||||
| run_js(js).strip.should == "foo" | |||||
| end | end | ||||