allow views to add content to the layout

21 views
Skip to first unread message

Julien Ammous

unread,
Aug 20, 2013, 5:47:32 AM8/20/13
to scor...@googlegroups.com
In sinatra there is a content_for() method (I think this is provided by an external gem) allowing you to add stylesheets, javascripts or anything else.
is there something like this built in scorched ?

here is the sinatra version: https://github.com/sinatra/sinatra-contrib/blob/master/lib/sinatra/content_for.rb

Tom Wardrop

unread,
Aug 20, 2013, 9:07:56 AM8/20/13
to Julien Ammous, scor...@googlegroups.com

Layouts are processed after the view, so anything you set in the view can be later accessed by the layout. Both the view and layout are rendered in the context of the controller instance where render was called, so a convenient method for sharing data between view and layout is to use instance variables, e.g @page_title.

I'm typing this in bed on my phone, but hopefully that can point you in the right direction in the mean time.

Cheers,
Tom

Schmurfy

unread,
Aug 21, 2013, 5:44:10 AM8/21/13
to Tom Wardrop, scor...@googlegroups.com
thanks I should be able to work it out knowing that they share the same context.
Reply all
Reply to author
Forward
0 new messages