1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Change the text for the Haml indentation errors.

This commit is contained in:
Nathan Weizenbaum 2008-04-18 12:13:35 -07:00
parent f42645050a
commit fec9af264b
2 changed files with 17 additions and 8 deletions

View file

@ -162,8 +162,9 @@ END
end
if old_line.spaces != old_line.tabs * 2
raise SyntaxError.new("Illegal indentation: only two space characters are allowed as tabulation.",
1 + old_line.index - @index)
raise SyntaxError.new(<<END.strip, 1 + old_line.index - @index)
#{old_line.spaces} space#{old_line.spaces == 1 ? ' was' : 's were'} used for indentation. Haml must be indented using two spaces.
END
end
unless old_line.text.empty? || @haml_comment
@ -171,8 +172,9 @@ END
end
if !flat? && line.tabs - old_line.tabs > 1
raise SyntaxError.new("Illegal indentation: indenting more than once per line is illegal.",
1 + old_line.index - @index)
raise SyntaxError.new(<<END.strip, 1 + old_line.index - @index)
#{line.spaces} spaces were used for indentation. Haml must be indented using two spaces.
END
end
old_line = line
newline
@ -723,7 +725,10 @@ END
spaces = line.index(/([^ ]|$)/)
if line[spaces] == ?\t
return nil if line.strip.empty?
raise SyntaxError.new("Illegal indentation: only two space characters are allowed as tabulation.", 2)
raise SyntaxError.new(<<END.strip, 2)
A tab character was used for indentation. Haml must be indented using two spaces.
Are you sure you have soft tabs enabled in your editor?
END
end
[spaces, spaces/2]
end

View file

@ -13,9 +13,13 @@ class EngineTest < Test::Unit::TestCase
"~" => "Tag has no content.",
"=" => "Tag has no content.",
"%p/\n a" => "Illegal nesting: nesting within an atomic tag is illegal.",
"%p\n\ta" => "Illegal indentation: only two space characters are allowed as tabulation.",
"%p\n a" => "Illegal indentation: only two space characters are allowed as tabulation.",
"%p\n a" => "Illegal indentation: indenting more than once per line is illegal.",
"%p\n\ta" => <<END.strip,
A tab character was used for indentation. Haml must be indented using two spaces.
Are you sure you have soft tabs enabled in your editor?
END
"%p\n a" => "1 space was used for indentation. Haml must be indented using two spaces.",
"%p\n a" => "3 spaces were used for indentation. Haml must be indented using two spaces.",
"%p\n a" => "4 spaces were used for indentation. Haml must be indented using two spaces.",
":a\n b" => 'Filter "a" is not defined.',
":a= b" => 'Invalid filter name ":a= b".',
"." => "Illegal element: classes and ids must have values.",