public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Make '- end' an error in Haml with a useful error message.
nex3 (author)
Mon Jul 14 18:10:52 -0700 2008
commit  b54ff8dbe6a33bdb9f43b0113e49f1b744b38892
tree    925af7914903b1f756b70d50849307ac0e3487a5
parent  82a2571e683c187cdbf42527a168854b914baae6
...
197
198
199
 
 
 
 
 
 
 
 
200
201
202
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
0
@@ -197,6 +197,14 @@ END
0
       when SILENT_SCRIPT
0
         return start_haml_comment if text[1] == SILENT_COMMENT
0
 
0
+ raise SyntaxError.new(<<END.rstrip, index) if text[1..-1].strip == "end"
0
+You don't need to use "- end" in Haml. Use indentation instead:
0
+- if foo?
0
+ %strong Foo!
0
+- else
0
+ Not foo.
0
+END
0
+
0
         push_silent(text[1..-1], true)
0
         newline_now
0
         if (@block_opened && !mid_block_keyword?(text)) || text[1..-1].split(' ', 2)[0] == "case"
...
34
35
36
 
 
 
 
 
 
 
37
38
39
...
34
35
36
37
38
39
40
41
42
43
44
45
46
0
@@ -34,6 +34,13 @@ END
0
     "%a/ b" => "Self-closing tags can't have content.",
0
     " %p foo" => "Indenting at the beginning of the document is illegal.",
0
     " %p foo" => "Indenting at the beginning of the document is illegal.",
0
+ "- end" => <<END.rstrip,
0
+You don't need to use "- end" in Haml. Use indentation instead:
0
+- if foo?
0
+ %strong Foo!
0
+- else
0
+ Not foo.
0
+END
0
     " \n\t\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
0
 
0
     # Regression tests

Comments

  • Peeja Tue Jul 15 05:42:27 -0700 2008

    Now, that’s self-documenting code! :)