Re: [Rails] <%= %> Interpolation question
On Sat, 2010-02-27 at 07:08 -0800, Dudebot wrote:
> Is there a way to get a Rails view to interpolate inside <%= %>?
> E.g. if foo = '<%= bar %>' and bar = '2',
> to have some variant of <%= foo %> in app/views/whatever/
> whatever.html.erb display '2' rather than '<%= bar %>'?
----
lots of ways... choose whatever is best for the situation...
<%= @foo == 'bar' ? "result 1" : "result 2" %>
or
<% if @foo == 'bar' -%>
<%= 'result 1' %>
<% else -%>
<%= 'result 2' %>
<% end -%>
Craig
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home