Using Nested Layouts in Plugin Development?
Added by Thorsten Merten about 14 years ago
Hello everybody,
the Plugin_Tutorial uses content_for
to "extend" the Redmine-Base-Layout (source:/trunk/app/views/layouts/base.rhtml). I use the same method in a nested layout for a plugin (as described here).
Anyway, content_for
works for named yields, only and I'd like to use the nested layout to render stuff in the "content" yield (precisely: the content-div).
Did I miss an elegant way to do so? Well, there are hooks, but they are called on every Redmine page...
If I did not miss anything: You could do a <%= yield :content %>
after the <%= yield %>
in base.rhtml
. For (soon to be coming ;) ) users of nested layouts, this might make sense at more places in base.rhtml
(at the same places the hooks are called...). This way plug-in-develops could extend a layout by doing something like:
# vendor/plugins/my_plugin/app/views/layouts/my_layout.rhtml <% content_for :content do%> ASDF <% end %> ... <%= render :file => 'layouts/base' %> # vendor/plugins/my_plugin/app/controllers/my_plugins_base_controller.rb ... layout proc{ |c| c.request.xhr? ? false : "my_layout" } ...
Cheers,
Thorsten