Skip to content

Commit

Permalink
Updated the partials entry in the FAQ
Browse files Browse the repository at this point in the history
... with a more robust partials implementation that is
adapted from Chris Schneider's implementation.
  • Loading branch information
lenary authored and rtomayko committed Oct 22, 2009
1 parent f4c6e5b commit 6bd4ca1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions faq.markdown
Expand Up @@ -127,10 +127,21 @@ follows:

<%= erb(:mypartial, :layout => false) %>

See [Chris Schneider](http://www.gittr.com/)'s
[partials.rb](http://github.com/cschneid/irclogger/blob/master/lib/partials.rb)
See [Sam Elliott](http://www.lenary.co.uk/)'s
[partials.rb](http://gist.github.com/119874)
for a more robust partials implementation. It even supports rendering
collections.
collections and partials in subdirectories. It was adapted from [Chris Schneider](http://www.gittr.com/)'s
[partials.rb](http://github.com/cschneid/irclogger/blob/master/lib/partials.rb) implementation to remove dependency on `#extract_options!` and add subdirectory support.

Use it as follows to render the `_mypartial.erb`(1) or the `admin/_mypartial.erb`(2) partials, or with a collection (3) & (4):

<%= partial(:mypartial) %> <!--(1)-->
<%= partial(:'admin/mypartial') %> <!--(2)-->
<%= partial(:object, :collection => @objects) %> <!--(3)-->
<%= partial(:'admin/object', :collection => @objects) %> <!--(4)-->

In (1) & (2), the partial will be rendered plain from their files, with no local variables (specify them with a hash passed into `:locals`). In (3) & (4), the partials will be rendered, populating the local variable `object` with each of the objects from the collection.


Can I have multiple URLs trigger the same route/handler? {#multiroute}
--------------------------------------------------------
Expand Down

0 comments on commit 6bd4ca1

Please sign in to comment.