Django-like nested templates with Rails layouts

Hi everyone

I've been briefly flirting with Django, and have decided that I'm going to stick with Ruby on Rails for the time being. The only thing I think I'm going to miss is Django's implementation of nested templates.

Thinking my way through it now, the closest I can think of would be to bundle the common content off into a load of partials (say "header", "menu", "footer" and so on). While this is better in that changing things within the partials would be accomplished in just one place, but it would still result in a bunch of files with very similar content, that would all need amending should I want to add an extra partial to each layout.

Has anyone got any strategies or ideas for accomplishing gives you?

Thanks Jon

I don't know, what exactly "nested templates" in Django do...

But you can nest partials into each other as deep as you like, you can even nest one in itself recursively. <%= render :template => "another_partial" %> or you can use the content_for thingy in a layout (eg for the menu part)

say: <%= yield :some_menu %>

and then in the partial to be rendered: <% content_for :some_menu %>   .. some html here...   ...or another render :partial => :whatever_menu... <% end %>

There are so many ways to define & render partials, hand in some data to them with :locals, :object and so on, that I can't imagine much you ould not do with them.

If you want to nest layouts within layouts (which it doesn't appear you want to do, but I think it's worth mentioning anyway), you can use the nested_layouts plugin.