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

Fix signature of InstanceTag#content_tag.

InstanceTag#content_tag should take a block to match the signature of
ActionView::Helpers::TagHelper.

Closes gh-443
This commit is contained in:
Alex Kwiatkowski, Ben Moss & Peter Jaros 2011-10-14 17:41:06 -04:00 committed by Nathan Weizenbaum
parent cee5b017be
commit 37235d738c
2 changed files with 20 additions and 3 deletions

View file

@ -130,7 +130,8 @@ module ActionView
end end
class InstanceTag class InstanceTag
# Includes TagHelper # Already includes TagHelper
include Haml::Helpers
def haml_buffer def haml_buffer
@template_object.send :haml_buffer @template_object.send :haml_buffer
@ -140,8 +141,8 @@ module ActionView
@template_object.send :is_haml? @template_object.send :is_haml?
end end
def content_tag(*args) def content_tag(*args, &block)
html_tag = content_tag_with_haml(*args) html_tag = content_tag_with_haml(*args, &block)
return html_tag unless respond_to?(:error_wrapping) return html_tag unless respond_to?(:error_wrapping)
return error_wrapping(html_tag) if method(:error_wrapping).arity == 1 return error_wrapping(html_tag) if method(:error_wrapping).arity == 1
return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on) return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on)

View file

@ -297,6 +297,22 @@ HAML
end end
end end
if ActionPack::VERSION::MAJOR >= 3
# Rails 3's #label helper can take a block.
def test_form_builder_label_with_block
assert_equal(<<HTML, render(<<HAML, :action_view))
<form #{rails_form_attr}action="" method="post">#{rails_form_opener}
<label for="article_title">Block content
</label>
</form>
HTML
#{rails_block_helper_char} form_for #{form_for_calling_convention(:article)}, :url => '' do |f|
= f.label :title do
Block content
HAML
end
end
## XSS Protection Tests ## XSS Protection Tests
# In order to enable these, either test against Rails 3.0 # In order to enable these, either test against Rails 3.0