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

前端 未结 2 1007
攒了一身酷
攒了一身酷 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:49

    Before Rails 3, ERB adds additional spaces before and after the value when rendering the HTML content. In HTML spaces are not significant, except when you are using special tags such as

    .

    Using the - sign forced ERB to avoid additional spaces.

    This is completely useless in Rails 3.

提交回复
热议问题