Can some one please describe the usage of the following characters which is used in ERB file:
<% %>
<%= %>
<% -%>
<%# %>
<% %>
executes the code in there but does not print the result, for eg:
We can use it for if else in an erb file.
<% temp = 1 %>
<% if temp == 1%>
temp is 1
<% else %>
temp is not 1
<%end%>
Will print temp is 1
<%= %>
executes the code and also prints the output, for eg:
We can print the value of a rails variable.
<% temp = 1 %>
<%= temp %>
Will print 1
<% -%>
It makes no difference as it does not print anything, -%>
only makes sense with <%= -%>
, this will avoid a new line.
<%# %>
will comment out the code written within this.