mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix interpolated comments breaking tabulation
When interpolating single line comments, use the nuke_inner_whitespace option to prevent format_script from decrementing the @real_tabs variable in the buffer, which can result in issues later in the Haml. This is admittedly a bit of a hack, cased by the number of params for format_script and the number of routes through that method. Other parts of the compiler explicitly emit code to add the extra tab to take this into account, which is arguably worse.
This commit is contained in:
parent
2b818b71b8
commit
05a23576a2
2 changed files with 6 additions and 1 deletions
|
@ -243,7 +243,7 @@ END
|
|||
push_merged_text("#{open} ")
|
||||
|
||||
if @node.value[:parse]
|
||||
push_script(@node.value[:text], :in_tag => true)
|
||||
push_script(@node.value[:text], :in_tag => true, :nuke_inner_whitespace => true)
|
||||
else
|
||||
push_merged_text(@node.value[:text], 0, false)
|
||||
end
|
||||
|
|
|
@ -1268,6 +1268,11 @@ HAML
|
|||
render('/ Hello #{1 + 1}', :suppress_eval => true))
|
||||
end
|
||||
|
||||
def test_single_line_comments_with_interpolation_dont_break_tabulation
|
||||
assert_equal("<!-- Hello 2 -->\nconcatted\n",
|
||||
render("/ Hello \#{1 + 1}\n- haml_concat 'concatted'"))
|
||||
end
|
||||
|
||||
def test_balanced_conditional_comments
|
||||
assert_equal("<!--[if !(IE 6)|(IE 7)]> Bracket: ] <![endif]-->\n",
|
||||
render("/[if !(IE 6)|(IE 7)] Bracket: ]"))
|
||||
|
|
Loading…
Reference in a new issue