Thanks for the reply Jacob. That blog post was actually one of the
first links I came across.
I liked the idea for conditionals like this example:
<%= (sidebar = yield :sidebar) ? sidebar : render(:partial =>
'shared/sidebar') %>
I guess I could do something like so:
view.rhtml:
<% content_for :sidebar do %>
<div id="sidebar">
all of my content in here
</div>
<% end %>
and then in my layout:
<%= (sidebar = yield :sidebar) ? sidebar : '' %>
but I'm still having to type that sidebar div everytime.
On May 24, 4:32 pm, Jacob Atzen <
j...@...> wrote:
> 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-~----------~----~----~----~------~----~------~--~---