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

Implement basic silent script

This commit is contained in:
Takashi Kokubun 2015-10-17 15:12:58 +09:00
parent 0361d407a8
commit 6d8f13cba2
2 changed files with 7 additions and 3 deletions

View file

@ -35,7 +35,7 @@ module Hamlit
when :script when :script
compile_script(node) compile_script(node)
when :silent_script when :silent_script
[:multi] compile_silent_script(node)
when :tag when :tag
compile_tag(node) compile_tag(node)
when :haml_comment when :haml_comment
@ -65,6 +65,10 @@ module Hamlit
[:static, node.value[:text]] [:static, node.value[:text]]
end end
def compile_silent_script(node)
[:code, node.value[:text]]
end
def compile_script(node) def compile_script(node)
if node.value[:preserve] if node.value[:preserve]
[:dynamic, %Q[Haml::Helpers.find_and_preserve(#{node.value[:text]}, %w(textarea pre code))]] [:dynamic, %Q[Haml::Helpers.find_and_preserve(#{node.value[:text]}, %w(textarea pre code))]]

View file

@ -1561,7 +1561,7 @@ HAML
render("%div{:foo => {:baz => 'bang'}}")) render("%div{:foo => {:baz => 'bang'}}"))
end end
def test_arbitrary_attribute_hash_merging; skip # silent script def test_arbitrary_attribute_hash_merging
assert_equal(%Q{<a aria-baz='qux' aria-foo='bar'></a>\n}, render(<<-HAML)) assert_equal(%Q{<a aria-baz='qux' aria-foo='bar'></a>\n}, render(<<-HAML))
- h1 = {:aria => {:foo => :bar}} - h1 = {:aria => {:foo => :bar}}
- h2 = {:baz => :qux} - h2 = {:baz => :qux}
@ -1755,7 +1755,7 @@ HAML
# Ruby Multiline # Ruby Multiline
def test_silent_ruby_multiline; skip # silent script def test_silent_ruby_multiline
assert_equal(<<HTML, render(<<HAML)) assert_equal(<<HTML, render(<<HAML))
bar, baz, bang bar, baz, bang
<p>foo</p> <p>foo</p>