« Return to Thread: content_for best practices

content_for best practices

by Josh Kieschnick :: Rate this Message:

Reply to Author | View in Thread


recently i ready about using content_for to add more dynamic control
in my layouts.

wanting to keep DRY, i'm wondering what the best way is to use this is
if i'm wanting to check specific areas for content. based on if there
is or isn't, i would like to totally remove or add elements to the
page.

while the example i am including works, it seems like this would
probably be creating a lot more work than necessary...

<% if(yield :sidebar) %>
  <div id="sidebar">
    <%= yield :sidebar %>
  </div>
<% end %>

if this isn't a good way of doing it, please let me know why. and if
there is an easy / clean way of doing it.

Thanks for the help


--~--~---------~--~----~------------~-------~--~----~
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