Forum: Ruby on Rails Throw default text when yield doesn't render anything ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nicolas C. (Guest)
on 2007-01-18 16:25
(Received via mailing list)
hello,

I'm wondering if there's a way to do something like : <%=
yield :catchphrase || "default text" %> ?

Thanks.
--
Nicolas C.
http://www.bounga.org
http://www.cavigneaux.net
Nicolas C. (Guest)
on 2007-01-18 16:28
(Received via mailing list)
Le 18 janv. 07 à 15:23, Nicolas C. a écrit :

>
> hello,
>
> I'm wondering if there's a way to do something like : <%=
> yield :catchphrase || "default text" %> ?

<%=  yield(:catchphrase) || "default text" %> works, sorry.
--
Nicolas C.
http://www.bounga.org
http://www.cavigneaux.net
(Guest)
on 2007-01-18 17:42
(Received via mailing list)
About time someone deprecate <%= @content_for_foo %> too. You should go
<%= yield(:foo) %> instead, and do <% if yield(:foo) %> (or perhaps
unless yield(:foo).empty? Not sure) if you need to check if it has
contents. Yield ftw!
This topic is locked and can not be replied to.