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

Merge commit 'mislav/stable' into stable

This commit is contained in:
Nathan Weizenbaum 2008-10-16 20:55:11 -07:00
commit 49be37b84f
2 changed files with 18 additions and 3 deletions

View file

@ -25,7 +25,7 @@ module Haml
if @@options[:rhtml]
match_to_html(template, /<%=(.*?)-?%>/m, 'loud')
match_to_html(template, /<%(.*?)-?%>/m, 'silent')
match_to_html(template, /<%-?(.*?)-?%>/m, 'silent')
end
method = @@options[:xhtml] ? Hpricot.method(:XML) : method(:Hpricot)
@ -166,8 +166,8 @@ module Haml
name, value = pair
unless value.empty?
full_match = nil
ruby_value = value.sub(%r{<haml:loud>\s*(.+?)\s*</haml:loud>}) do
full_match = $`.empty? and $'.empty?
ruby_value = value.gsub(%r{<haml:loud>\s*(.+?)\s*</haml:loud>}) do
full_match = $`.empty? && $'.empty?
full_match ? $1: "\#{#{$1}}"
end
unless ruby_value == value

View file

@ -61,6 +61,21 @@ class Html2HamlTest < Test::Unit::TestCase
render_rhtml(%Q{<div id="item_<%= i %>">Ruby string interpolation FTW</div>})
end
def test_rhtml_in_attribute_with_trailing_content
assert_equal %(%div{ :class => "\#{12}!" }\n Bang!),
render_rhtml(%Q{<div class="<%= 12 %>!">Bang!</div>})
end
def test_rhtml_in_attribute_to_multiple_interpolations
assert_equal %(%div{ :class => "\#{12} + \#{13}" }\n Math is super),
render_rhtml(%Q{<div class="<%= 12 %> + <%= 13 %>">Math is super</div>})
end
def test_whitespace_eating_erb_tags
assert_equal %(- form_for),
render_rhtml(%Q{<%- form_for -%>})
end
protected
def render(text, options = {})