show_for_tag is ignored on subsequent records when used with render :collection
blakehilscher opened this issue · 2 comments
blakehilscher commented
The html_options config is ignored on subsequent records when used with render :collection => @records
I'm also seeing duplication on the outputted classes created by show_for. See the output example below.
{:html_options => {:show_for_tag => :li}}
index.html.haml
= render :partial => 'testimonials/testimonial', :collection => @testimonials, :locals => {:html_options => {:show_for_tag => :li} }
_testimonial.html.haml
= show_for(testimonial, html_options) do |r|
= r.attribute :title
= r.attribute :content
= r.attribute :author
= r.attribute :company
Outputs:
<li id="testimonial_1" class="show_for testimonial">...</li>
<div id="testimonial_1" class="show_for testimonial show_for testimonial">...</div>
<div id="testimonial_1" class="show_for testimonial show_for testimonial show_for testimonial">...</div>
<div id="testimonial_1" class="show_for testimonial show_for testimonial show_for testimonial show_for testimonial">...</div>
This is being caused by lib/show_for/helper.rb #13
tag = html_options.delete(:show_for_tag) || ShowFor.show_for_tag
rafaelfranca commented
Thanks. I can work on it later but you can open a pull request if you want.
You just need to do:
def show_for(object, html_options={}, &block)
html_options = html_options.dup
tag = html_options.delete(:show_for_tag) || ShowFor.show_for_tag
...
and add tests.
blakehilscher commented
fixed ref #46