Make '- end' an error in Haml with a useful error message.

This commit is contained in:
Nathan Weizenbaum 2008-07-14 21:10:52 -04:00
parent 82a2571e68
commit b54ff8dbe6
2 changed files with 15 additions and 0 deletions

View File

@ -197,6 +197,14 @@ END
when SILENT_SCRIPT
return start_haml_comment if text[1] == SILENT_COMMENT
raise SyntaxError.new(<<END.rstrip, index) if text[1..-1].strip == "end"
You don't need to use "- end" in Haml. Use indentation instead:
- if foo?
%strong Foo!
- else
Not foo.
END
push_silent(text[1..-1], true)
newline_now
if (@block_opened && !mid_block_keyword?(text)) || text[1..-1].split(' ', 2)[0] == "case"

View File

@ -34,6 +34,13 @@ END
"%a/ b" => "Self-closing tags can't have content.",
" %p foo" => "Indenting at the beginning of the document is illegal.",
" %p foo" => "Indenting at the beginning of the document is illegal.",
"- end" => <<END.rstrip,
You don't need to use "- end" in Haml. Use indentation instead:
- if foo?
%strong Foo!
- else
Not foo.
END
" \n\t\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
# Regression tests