Render :partial in /app/views/layouts

Hi all,

I have many layouts that apply to parts of my Rails site. Some of the
elements of each of the layouts are the same. I would like to create
something like a partial to use within layouts.

For example, I might have two layouts that have identical
information, but different formatting.

Is there a way to separate out the identical information so I can DRY
up my layout code? I didn’t have much luck creating partials in the
layout directory.

Thanks,
trv

After doing some searching I found nested-layouts (http://github.com/
radar/nested-layouts/tree/master). It seems to do the trick, although
to get it to work with my Rails 2.3.2 app, I had to change part of
line 13 of lib/nested_layouts.rb from ‘app/views/layouts’ to “#
{RAILS_ROOT}/app/views/layouts”

If anyone has some better/alternative solutions, I am all ears.

trv

Actually partials in the layout directory work fine (like in any other
dir), but you need to specify the directory explicitly:

layouts/
_head.html.erb
application.html.erb

In application.html.erb
<%= render :partial => ‘layouts/head’ %>

Dmitry