Permalink
Browse files

Check for error on inverting an unopened section

  • Loading branch information...
1 parent 62d8591 commit 634901e702eccf77e2a6594313c7c7fd9e7497a0 @MSch committed Sep 10, 2010
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/handlebars/parser.rb
  2. +11 −0 spec/parser_spec.rb
@@ -131,7 +131,7 @@ def find_context
section, pos, result = @sections.pop
@result = result
if section.nil?
- error "Inverting unopened #{content.inspect}"
+ error "Inverting unopened section"
end
# Open a new inverted section with the same name
View
@@ -3,6 +3,17 @@
describe Handlebars::Parser do
+ it 'fails when the handlebars inverted section syntax is used without an opened section' do
+ lexer = Handlebars::Parser.new
+ proc {
+ lexer.compile(<<-EOF)
+{{^}}
+<h1>No projects</h1>
+{{/project}}
+EOF
+ }.should raise_error(Handlebars::Parser::SyntaxError)
+ end
+
it 'parses the handlebars inverted section syntax' do
lexer = Handlebars::Parser.new
tokens = lexer.compile(<<-EOF)

0 comments on commit 634901e

Please sign in to comment.