« Return to Thread: content_for best practices

Re: content_for best practices

by Jacob Atzen-3 :: Rate this Message:

Reply to Author | View in Thread


Josh wrote:

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

Maybe you can find some inspiration from Err:

http://errtheblog.com/post/28

--
Cheers,
- Jacob Atzen

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