"<%= %>", "<%- %>" and "<% -%>"

When I want to show output,
“<%= %>”
When I do not want to show output,
“<%- %>” or “<% %>”
What about this?
“<% -%>”
Is this same as “<%- %>”?

-duke

the hyphens suppress newlines. i’m not sure if the single versions are
equal, but i double them up just out of habit: <%- … -%>

-eric

On Oct 21, 12:21 pm, Duke Y. [email protected]

Duke Y. wrote:

When I want to show output,
“<%= %>”
When I do not want to show output,
“<%- %>” or “<% %>”
What about this?
“<% -%>”
Is this same as “<%- %>”?

<%# %> or <%# -%>
For commenting out ERB code.

Robert W. wrote:

Duke Y. wrote:

When I want to show output,
“<%= %>”
When I do not want to show output,
“<%- %>” or “<% %>”
What about this?
“<% -%>”
Is this same as “<%- %>”?

<%# %> or <%# -%>
For commenting out ERB code.

I’m seeing code,
<% if flash[:error] -%>
<%= flash[:error] %>
<% end -%>
It works fine.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs