# Partials with yield

**URL:** <https://www.ruby-forum.com/t/partials-with-yield/118588>\
**Category:** Rails\
**Created:** [October 29, 2007, 9:17am UTC](https://www.ruby-forum.com/t/partials-with-yield/118588 "2007-10-29T09:17:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 29, 2007, 9:17am UTC](https://www.ruby-forum.com/t/partials-with-yield/118588/1 "2007-10-29T09:17:39Z")

</div>

I’m just wondering if you can use yield/closures in action view  
templates, it’s kind of hard to explain so I’ll use an example:

\<%= render(:partial =\> “table\_builder”, :locals =\> {:headings =\>  
[“name”, “id”], :collection =\> @users}) do |user| %\>  
#the partial build a table with the headings etc and then yields  
here for the row data

\<%= user.name %\>\<%=user.id %\>  
\<% end %\>

That abstracts all the table building etc into a partial and leaves  
the view specific stuff to the view, without needing another partial.

Is this possible with rails? I know it is in monorail but I haven’t  
seen it done with rails so any pointers would be appreciated.
