Skip to content

Commit

Permalink
Allow escape_attrs on a per-tag basis
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Jan 22, 2012
1 parent 630b8fe commit 19c7668
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/haml/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def self.build_attributes(is_html, attr_wrapper, escape_attrs, attributes = {})
quote_escape = attr_wrapper == '"' ? """ : "'"
other_quote_char = attr_wrapper == '"' ? "'" : '"'

# Allow escape_attrs on a per-tag basis
escape_attrs = attributes['escape_attrs'] if attributes.has_key?('escape_attrs')

if attributes['data'].is_a?(Hash)
attributes = attributes.dup
attributes =
Expand Down
11 changes: 11 additions & 0 deletions test/haml/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,17 @@ def test_escape_attrs_false
bar
HAML
end

def test_escape_attrs_can_be_overridden_in_tag
assert_equal(<<HTML, render(<<HAML, :escape_attrs => true))
<div class='<?php echo "&quot;" ?>' id='foo'>
bar
</div>
HTML
#foo{:class => '<?php echo "&quot;" ?>', :escape_attrs => false}
bar
HAML
end

def test_escape_attrs_always
assert_equal(<<HTML, render(<<HAML, :escape_attrs => :always))
Expand Down

0 comments on commit 19c7668

Please sign in to comment.