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

前端 未结 7 1619
一向
一向 2020-11-21 05:33

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

<%   %>
<%=  %>
<%  -%>
<%#  %>
         


        
7条回答
  •  灰色年华
    2020-11-21 06:05

    • <% %> : Executes the ruby code
    • <%= %> : Prints into Erb file. Or browser
    • <% -%> : Avoids line break after expression.
    • <%# %> : ERB comment

提交回复
热议问题