Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
756 views
in Technique[技术] by (71.8m points)

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

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

Example:

<% 3.times do -%>
  FooBar<br />
<% end -%>
Sometext

Regardless of whether I use '-' or not, a browser renders the same output.

Thanks, Aplha.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 <pre>.

Using the - sign forced ERB to avoid additional spaces.

This is completely useless in Rails 3.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...