Skip to content

Commit

Permalink
Fix signature of InstanceTag#content_tag.
Browse files Browse the repository at this point in the history
InstanceTag#content_tag should take a block to match the signature of
ActionView::Helpers::TagHelper.

Closes hamlgh-443
  • Loading branch information
Alex Kwiatkowski, Ben Moss & Peter Jaros authored and nex3 committed Nov 1, 2011
1 parent cee5b01 commit 37235d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/haml/helpers/action_view_mods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def content_tag_with_haml(name, *args, &block)
end

class InstanceTag
# Includes TagHelper
# Already includes TagHelper
include Haml::Helpers

def haml_buffer
@template_object.send :haml_buffer
Expand All @@ -140,8 +141,8 @@ def is_haml?
@template_object.send :is_haml?
end

def content_tag(*args)
html_tag = content_tag_with_haml(*args)
def content_tag(*args, &block)
html_tag = content_tag_with_haml(*args, &block)
return html_tag unless respond_to?(:error_wrapping)
return error_wrapping(html_tag) if method(:error_wrapping).arity == 1
return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on)
Expand Down
16 changes: 16 additions & 0 deletions test/haml/template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ def test_av_block_deprecation_warning
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

# In order to enable these, either test against Rails 3.0
Expand Down

0 comments on commit 37235d7

Please sign in to comment.