Ben Lisbakken
2006-Jul-19 23:10 UTC
[Rails] Using Application.rhtml as layout for all controllers
I put my nav system in application layout. that way any controller loading will have the nav system. I have one problem though - the <%= yield %> is in the body, so how would my controllers specify other css files? my application layout would look like this: <html> <head> title css include javascript include </head> <body> nav system <%=yield%> </body> </html> so that means any controllers go into the body immediatly - so can they not have their own css files without specifying them in application layout? Thanks, Ben Lisbakken -- Posted via http://www.ruby-forum.com/.
Josh Knowles
2006-Jul-19 23:18 UTC
[Rails] Using Application.rhtml as layout for all controllers
On 7/19/06, Ben Lisbakken <lisbakke@gmail.com> wrote:> > I put my nav system in application layout. that way any controller > loading will have the nav system. I have one problem though - the <%> yield %> is in the body, so how would my controllers specify other css > files?Check out the Cascading Stylesheets Plugin: http://www.redhillconsulting.com.au/rails_plugins.html#cascading_stylesheets It will let you have a seperate style sheet for application -> controller -> action Josh -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060719/93877ade/attachment.html
Ben Lisbakken
2006-Jul-19 23:31 UTC
[Rails] Re: Using Application.rhtml as layout for all controllers
Josh Knowles wrote:> On 7/19/06, Ben Lisbakken <lisbakke@gmail.com> wrote: >> >> I put my nav system in application layout. that way any controller >> loading will have the nav system. I have one problem though - the <%>> yield %> is in the body, so how would my controllers specify other css >> files? > > > > Check out the Cascading Stylesheets Plugin: > http://www.redhillconsulting.com.au/rails_plugins.html#cascading_stylesheets > > It will let you have a seperate style sheet for application -> > controller -> > action > > Joshawesome thanks Josh! -Ben Lisbakken -- Posted via http://www.ruby-forum.com/.
Jean-François
2006-Jul-19 23:41 UTC
[Rails] Using Application.rhtml as layout for all controllers
Hello Ben,> I put my nav system in application layout. that way any controller > loading will have the nav system. I have one problem though - the <%> yield %> is in the body, so how would my controllers specify other css > files?You can specify parts of code that will be used in layout, like with yield / @content_for_layout system. yield :foo is the same as @content_for_foo, but the first syntax is now preferred.> my application layout would look like this: > <html> > <head> > title > css include > javascript includehere put a <%= yield :specific_css %> for example.> </head> > <body> > nav system > <%=yield%> > </body> > </html>And in your view : <% content_for :specific_css do -%> <%= stylesheet_link_tag "foo" %> other code if you want... <% end -%> See http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#M000528 for further information.> so that means any controllers go into the body immediatly - so can they > not have their own css files without specifying them in application > layout?-- Jean-Fran?ois. -- ? la renverse.
Jamie Quint
2006-Jul-19 23:43 UTC
[Rails] Re: Using Application.rhtml as layout for all controllers
Ripped off from a post yesterday (Credit to Richard Livsey), this may help.... Take a look at: http://api.rubyonrails.com/classes/ActionView/Helpers/CaptureHelper.html Specifically: In your layout: <head> ... stuff <%= @content_for_head %> </head> In your template: <% content_for("head") do %> the javascript / include js file <% end %> On 7/19/06, Ben Lisbakken <lisbakke@gmail.com> wrote:> > Josh Knowles wrote: > > On 7/19/06, Ben Lisbakken <lisbakke@gmail.com> wrote: > >> > >> I put my nav system in application layout. that way any controller > >> loading will have the nav system. I have one problem though - the <%> >> yield %> is in the body, so how would my controllers specify other css > >> files? > > > > > > > > Check out the Cascading Stylesheets Plugin: > > > http://www.redhillconsulting.com.au/rails_plugins.html#cascading_stylesheets > > > > It will let you have a seperate style sheet for application -> > > controller -> > > action > > > > Josh > > awesome thanks Josh! > > -Ben Lisbakken > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060719/6e41b192/attachment.html