Perfect. Thanks man!

# render a partial with a block
def partial_wrapper(template, options={}, &block)
  throw_content(:for_layout, block_given? ? capture(&block) : "")
  partial(template, options)
end

Been combining all these awesome tricks into the ViewFu Merb plugin.
http://github.com/merbjedi/viewfu

Pretty killer collection already. Nested Layouts and Partial
Templates. Wonder what else we can add...


On Nov 24, 4:43 pm, "Yehuda Katz" <[EMAIL PROTECTED]> wrote:
> Try this:
> ## in your helper
>   def layout_partial(name, &blk)
>     throw_content(:for_layout, capture(&blk))
>     partial(name)
>   end
>
> ## template
> <%= layout_partial(:partial) do %>
>   Inside
> <% end =%>
>
> ## partial
> Hello
> <%= catch_content(:for_layout) %>
> Goodbye
>
> -- Yehuda
>
>
>
> On Mon, Nov 24, 2008 at 4:24 PM, Jacques Crocker <[EMAIL PROTECTED]> wrote:
>
> > Ran into another thing in Rails that I don't see a way to do in Merb.
> > Would love some guidance on how to yield in partials, or some other
> > mechanism to turn a partial into a layout.
>
> > I often use yield in partials so I can build that partial as a wrapper
> > around some content that I specify in a block.
>
> > For example:
>
> > -# In Rails...
> > - render :layout => "shared/collapse_box" do
> >  = "wrapped partial content here"
>
> > Kind of clunky, which is one reason I built the "better partials"
> > pluginhttp://github.com/jcnetdev/better_partialsplugin in order to
> > get around this.
>
> > -# In Rails...
> > - partial "shared/collapse_box" do
> >  = "wrapped partial content here"
>
> > All this does is checks if a block is given. If so it converts to
> > the :layout option.
>
> > Anyways, I'd really like this functionality somehow in Merb.
>
> > Now I was able to *almost* get it working using Yehuda's excellent
> > render :layout trick, and just using the standard content catching and
> > throwing for layouts. Now the problem here is that :layout will always
> > force me into the layout/ folder for my templates.
>
> > Is there any way to run render content, :layout => "xxx" without the
> > assumption that we are going into the layout folder? Or is there
> > another helper I should look at to render my partials with content
> > blocks?
>
> > Thanks
>
> --
> Yehuda Katz
> Developer | Engine Yard
> (ph) 718.877.1325
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to