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)
|
def compile_html_comment(node, &block)
|
||||||
if node.children.empty?
|
if node.children.empty?
|
||||||
[:html, :comment, [:static, " #{node.value[:text]} "]]
|
[:html, :comment, compile_text(node)]
|
||||||
else
|
else
|
||||||
[:html, :comment, yield(node)]
|
[:html, :comment, yield(node)]
|
||||||
end
|
end
|
||||||
|
@ -28,12 +28,24 @@ module Haml
|
||||||
|
|
||||||
content =
|
content =
|
||||||
if node.children.empty?
|
if node.children.empty?
|
||||||
[:static, " #{node.value[:text]} "]
|
compile_text(node)
|
||||||
else
|
else
|
||||||
yield(node)
|
yield(node)
|
||||||
end
|
end
|
||||||
[:html, :condcomment, condition, content, node.value[:revealed]]
|
[:html, :condcomment, condition, content, node.value[:revealed]]
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,10 @@ describe Haml::Engine do
|
||||||
assert_render(%Q|<!-- comments -->\n|, '/ comments')
|
assert_render(%Q|<!-- comments -->\n|, '/ comments')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'renders intepolation' do
|
||||||
|
assert_render(%Q|<!-- comments -->\n|, '/ #{"comments"}')
|
||||||
|
end
|
||||||
|
|
||||||
it 'strips html comment ignoring around spcaes' do
|
it 'strips html comment ignoring around spcaes' do
|
||||||
assert_render(%Q|<!-- comments -->\n|, '/ comments ')
|
assert_render(%Q|<!-- comments -->\n|, '/ comments ')
|
||||||
end
|
end
|
||||||
|
@ -61,6 +65,7 @@ describe Haml::Engine do
|
||||||
world
|
world
|
||||||
HAML
|
HAML
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders conditional comment' do
|
it 'renders conditional comment' do
|
||||||
assert_render(<<-HTML.unindent, <<-'HAML'.unindent)
|
assert_render(<<-HTML.unindent, <<-'HAML'.unindent)
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
|
|
Loading…
Reference in a new issue