Robert Head wrote:
<% if !foo.blank? %> <div class="foo_class"><%= foo %></div> <% end %>
The elemental they mentioned in a previous message looks great. I have also found this helper useful.
# Will print the content in the given tag if the condition is true. If # no condition is provided then it will use the existance of real data # in the content value to determine if content should be printed def if_tag(tag_name, content, html_options={},condition=!content.blank?) content_tag(tag_name, content, html_options) if condition end
I use would reproduce what you were trying to do with:
<%=if_tag('div', foo, :class=>'foo_class')%>
Eric