On 19/10/2010, at 5:56 PM, Xavier Shay wrote:

> On 19/10/10 1:46 PM, Steve H wrote:
>> I'm trying to find a good way to set up variables related to a web
>> page but not the page itself, for example:
>> 
>> * the page title
>> * the<meta>  description
>> * whether it is the currently active tab
>> * the breadcrumbs that lead to the page
>> 
>> and so on.
>> 
>> I don't think it really belongs in the controller, but specifying it
>> manually in the top of the view is a bit hairy too. How do you do it?
>> 
> I put it at the top of the view for which it is relevant.
> Note this may be a partial! (such as including JS for a form)
> I haven't found it complicated enough to require an external dependency.
> 
> - content_for(:page_title) do
>  Hello this is a page
> - content_for(:js) do
>  = javascript_include_tag 'dynamic-form-stuff'

You can also pass a string to content_for:

- content_for :page_title, "Hello this is a page"
- content_for :js, javascript_include_tag("dynamic-form-stuff")

– tim

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to