HiveBrain v1.2.0
Get Started
← Back to all entries
gotcharubyrailsCritical

What is the difference between <%, <%=, <%# and -%> in ERB in Rails?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
andbetweenerbthedifferencewhatrails

Problem

Can some one please describe the usage of the following characters which is used in ERB file:



what's the usage of each one ?

Solution



Executes the ruby code within the brackets.



Prints something into erb file.



Equivalent to ``. Prints something verbatim (i.e. w/o escaping) into erb file. (Taken from Ruby on Rails Guides.)



Avoids line break after expression.



Comments out code within brackets; not sent to client (as opposed to HTML comments).

Visit Ruby Doc for more infos about ERB.

Context

Stack Overflow Q#7996695, score: 539

Revisions (0)

No revisions yet.