erubis icon indicating copy to clipboard operation
erubis copied to clipboard

Documentation and support for <% foo -%>?

Open xpe opened this issue 10 years ago • 2 comments

ERB has the whitespace / newline suppression feature, but I have not seen newline suppression of <% foo %> in mentioned in Erubis documentation anywhere. I've also tried it out with no luck. Is this by design?

xpe avatar Mar 31 '14 20:03 xpe

It's not very clearly documented: after many tests I think this is how it works: http://stackoverflow.com/a/25626629/895245

In particular:

  • <% %> only removes the line if the entire line contains only whitespaces
  • <%= -%> removes what comes after the tag if there are only whitespaces, regardeless of what comes before.
  • - without = makes no difference

cirosantilli avatar Sep 03 '14 15:09 cirosantilli

the absense of -%> support is problematic for me. I have something like:

var = <% if cond -%>
value1
<% elsif cond2 -%>
value2
<% else -%>
value3 that
is complicated and takes multiple lines
<% end -%>

tmccombs avatar Oct 13 '20 20:10 tmccombs