Add support for inverted sections in the parser

This commit is contained in:
wycats
2010-12-03 00:54:18 -05:00
parent 87b526df27
commit 8f6f3051e6
5 changed files with 27 additions and 5 deletions
+14 -2
View File
@@ -55,8 +55,8 @@ describe "Parser" do
with_padding { yield }
end
def block
pad("BLOCK:")
def block(inverse = false)
inverse ? pad("INVERSE:") : pad("BLOCK:")
with_padding { yield }
end
@@ -148,6 +148,18 @@ describe "Parser" do
end
end
it "parses a standalone inverse section" do
ast_for("{{^foo}}bar{{/baz}}").should == program do
block true do
mustache id("foo")
program do
content "bar"
end
end
end
end
it "raises if there's a Parse error" do
lambda { ast_for("{{foo}") }.should raise_error(V8::JSError, /Parse error on line 1/)
lambda { ast_for("{{foo &}}")}.should raise_error(V8::JSError, /Parse error on line 1/)