« Return to Thread: content_for best practices

Re: content_for best practices

by Josh Kieschnick :: Rate this Message:

Reply to Author | View in Thread


> def conditional_element(name)
>    element = yield(name.to_sym)
>    content_tag(:div, element, :id => name.to_s) if element
> end

I might could get something like that to work. Basically I am just
looking for a way to check and see if there is content for a specific
area and adjust my markup, ids and classes accordingly.

Say I have a 3 column layout, and if there is no sidebar content, i
want to be able to check and render a 2 column layout instead.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: content_for best practices