I have a main layout file that, depending on the @session[''user''] object, renders the appropriate layout file via render_partial: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link rel="stylesheet" href="/stylesheets/public.css"> <!-- Custom styles included by specific pages --> <style><%= @content_for_style %> </style> </head> <body> <% if @session[''user''].nil? # Member nor admin is not logged in %> <%= render_partial "/layouts/public_layout" %> <% elsif @session[''user''].admin? # Admin is logged in %> <%= render_partial "/layouts/admin_layout" %> <% else # Member is logged in %> <%= render_partial "/layouts/member_layout" %> <% end %> </body> </html> However, if I use the CaptureHelper''s "capture" method or content_for ("style") inside of these rendered partials, I don''t get anything in @content_for_style. On the other hand, if I use "capture" or content_for("style") in my view file, it works as expected. Is this simply a limitation of the CaptureHelper, or is there some other way? Thanks, Duane Johnson (canadaduane) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
can you post an example of a partial in question... i do this all the time and have no problem... Duane Johnson wrote:> I have a main layout file that, depending on the @session[''user''] > object, renders the appropriate layout file via render_partial: > > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; "> > <link rel="stylesheet" href="/stylesheets/public.css"> > <!-- Custom styles included by specific pages --> > <style><%= @content_for_style %> </style> > </head> > <body> > <% if @session[''user''].nil? # Member nor admin is not logged in %> > <%= render_partial "/layouts/public_layout" %> > <% elsif @session[''user''].admin? # Admin is logged in %> > <%= render_partial "/layouts/admin_layout" %> > <% else # Member is logged in %> > <%= render_partial "/layouts/member_layout" %> > <% end %> > </body> > </html> > > However, if I use the CaptureHelper''s "capture" method or > content_for("style") inside of these rendered partials, I don''t get > anything in @content_for_style. > > On the other hand, if I use "capture" or content_for("style") in my > view file, it works as expected. Is this simply a limitation of the > CaptureHelper, or is there some other way? > > Thanks, > Duane Johnson > (canadaduane) > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Duane Johnson wrote:> On the other hand, if I use "capture" or content_for("style") in my view > file, it works as expected. Is this simply a limitation of the > CaptureHelper, or is there some other way?The @content_for_... are evaluated only on the view files and not on the layout files, so you can''t put capture or content_for in layout files, only on the view files. rgds Dema http://dema.ruby.com.br/
Demetrius Nunes wrote:> Duane Johnson wrote: > >> On the other hand, if I use "capture" or content_for("style") in my >> view file, it works as expected. Is this simply a limitation of the >> CaptureHelper, or is there some other way? > > > The @content_for_... are evaluated only on the view files and not on > the layout files, so you can''t put capture or content_for in layout > files, only on the view files. >ummm no... i do it all the time and it works... _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails