What is that hyphen right before the closing of an ERb block?

Periodically, I see some ERb code in a view like this:


<% form_tag '/posts' do -%>

<%= submit_tag 'Save' %>
<% end -%>

In fact, that code was culled right from the Rails docs at for form_tag

As you can see, in those two ERb tags, there is this syntax at close of the tag:
-%>
Today I was wondering what the hyphen (-) was for before the percentage symbol (%). It turns out that the hyphen means that when the HTML output is generated there is no line return after the close of the ERb tag.

For example, the ERb code above produces this HTML:
<form action="/posts" method="post">    <div><input name="commit" type="submit" value="Save" /></div>
</form>

whereas this ERb code:
<% form_tag '/posts' do %>    
<%= submit_tag 'Save' %>
<% end %>

produces this HTML:
<form action="/posts" method="post">
<div><input name="commit" type="submit" value="Save" /></div>
</form>

No comments: