'-%>' (minus sign) at the end of a ERb sequence

前端 未结 2 987
攒了一身酷
攒了一身酷 2020-12-15 14:53

What\'s the point of using \'-\' (minus sign) at the end of a ERb sequence?

Example:

<% 3.times do -%>
  FooBar
<% end -%> So
2条回答
  •  有刺的猬
    2020-12-15 15:29

    Using a minus sign on the opening or closing part of an erb tag suppresses whitespace before or after the tag on that line.

    It was mainly useful when generating things like text/plain emails with erb but like @Simone pointed out, it's now moot.

提交回复
热议问题