On Jan 4, 2009, at 7:18 PM, James Englert wrote:

> Hey All,
>    I would like some logic that would help me determine whether a  
> yield has any content to it.  For example:
>
> <div class="submenu">
>     <%= yield :submenu %>
> </div>
>
> I only want to display the div around the yield if the yield will  
> have content.
>
> Any ideas?

You can do:

<% if !yield(:submenu).strip.blank? -%>
   <div class="submenu">
     <%= yield :submenu %>
   </div>
<% end -%>

The call may be expensive so you might want to create some other  
method of determining whether the submenu is likely to have content.  
But this should work.

HTH


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to