mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
parent
8610dc1824
commit
06920a2634
2 changed files with 19 additions and 2 deletions
|
@ -14,7 +14,7 @@ module Haml
|
|||
|
||||
def compile_html_comment(node, &block)
|
||||
if node.children.empty?
|
||||
[:html, :comment, [:static, " #{node.value[:text]} "]]
|
||||
[:html, :comment, compile_text(node)]
|
||||
else
|
||||
[:html, :comment, yield(node)]
|
||||
end
|
||||
|
@ -28,12 +28,24 @@ module Haml
|
|||
|
||||
content =
|
||||
if node.children.empty?
|
||||
[:static, " #{node.value[:text]} "]
|
||||
compile_text(node)
|
||||
else
|
||||
yield(node)
|
||||
end
|
||||
[:html, :condcomment, condition, content, node.value[:revealed]]
|
||||
end
|
||||
|
||||
def compile_text(node)
|
||||
text =
|
||||
if node.value[:parse]
|
||||
# Just always escaping the result for safety. We could respect
|
||||
# escape_html, but I don't see any use case for it.
|
||||
[:escape, true, [:dynamic, node.value[:text]]]
|
||||
else
|
||||
[:static, node.value[:text]]
|
||||
end
|
||||
[:multi, [:static, ' '], text, [:static, ' ']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe Haml::Engine do
|
|||
assert_render(%Q|<!-- comments -->\n|, '/ comments')
|
||||
end
|
||||
|
||||
it 'renders intepolation' do
|
||||
assert_render(%Q|<!-- comments -->\n|, '/ #{"comments"}')
|
||||
end
|
||||
|
||||
it 'strips html comment ignoring around spcaes' do
|
||||
assert_render(%Q|<!-- comments -->\n|, '/ comments ')
|
||||
end
|
||||
|
@ -61,6 +65,7 @@ describe Haml::Engine do
|
|||
world
|
||||
HAML
|
||||
end
|
||||
|
||||
it 'renders conditional comment' do
|
||||
assert_render(<<-HTML.unindent, <<-'HAML'.unindent)
|
||||
<!--[if lt IE 9]>
|
||||
|
|
Loading…
Reference in a new issue