Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set a tag of a collection rendering #6049

Closed
acapilleri opened this Issue · 4 comments

4 participants

@acapilleri

Could useful set the tag of a collection when you render it, like backboneJS?

for example , given a partial:

<span><%=post.autor%></span>
<span><%=post.created_at%></span>

you could render inside two different tags

<ul>
<%= render @posts,:tag=>'li'%>
</ul>

output:

<ul>
<li>
 <span>one</span> 
 <span>Tomorrow</span>
 </li>

<li>
 <span>two</span> 
 <span>Today</span>
 </li>
</ul> 

or

<div>
<%= render @posts,:tag=>'div'%>
</div>

output:

<div>
<div>
 <span>one</span> 
 <span>Tomorrow</span>
 </div>

<div>
 <span>two</span> 
 <span>Today</span>
 </div>
</div> 

or without any tag
i posted this, in the #6006

@steveklabnik
Collaborator

Feature requests without patches are better made to rails-core: http://groups.google.com/group/rubyonrails-core?pli=1

Issues are used mostly to manage bug reports and to talk about code. I'm afraid this will get lost. That said, I'm leaving it open to see if it generates any discussion. But if someone who's done this longer than me knows better...

@acapilleri

@steveklabnik thanks so much for the informations

@pixeltrix
Owner

Rendering a collection at the moment doesn't generate a tag - you could just do:

<%= content_tag_for(tag, post) do %>
<span><%= post.author %></span>
<span><%= post.created_at %></span>
<% end %>

<%= render @posts, :tag => :li %>
@pixeltrix pixeltrix closed this
@carlosantoniodasilva

As useful as it might be, I'll have to stick with my position that this is not render's responsibility. For this api to work, it would have to look like this with current rendering architecture:

  render partial: "post", collection: @posts, tag: "li"

It is not possible to only give a tag option when calling only render with a collection, the same way it's not possible to give layout or formats, you have to explicitly give :partial.

I don't see a real gain on adding the :tag as an option, considering it's possible to just add this to your partial in simpler scenarios, or to use partial layouts in other more complicated scenarios.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.