Ruby on Rails
Wednesday, July 30, 2014
<%= %> appends to the output and <% %> doesn't.
<% %> is for control statements such as `if`, whereas things that generate HTML or strings to be included in the document should use <%= %>.
For example:
<% if should_apologize? %>
<%= "I'm sorry #{name}." %>
<% else %>
<%= "I'm not sorry. You deserved it, #{name}." %>
<% end %>
On Wed, Jul 30, 2014 at 3:52 PM, Dan Boyle <dan.boyle.dc@gmail.com> wrote:
Hello,--I am very new to Ruby on Rails. I am working my way through the guides at rubyonrails.org. It isn't going very quickly but I am determined to make it work.Here is a very basic question but I just can't figure it out by looking at the examples. It is regarding embedded ruby.What is the difference between these two forms of embedded code.<%= ... some code ... %>and<% ... some code ... %>Some lines have the equal sign in it and most of them don't. I just want to know what the rule is for using either.Thanks.Dan
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e5814049-71fa-4096-a959-9b26a3b992a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Daniel Evans
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD2%3DUWWGLec3AN9XyV%3DTeDuYPiYD2HTv3SpT8B-KfEqD%2B%2BSh0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment