# \-%\> what this "-" for?

**URL:** <https://www.ruby-forum.com/t/what-this-for/170252>\
**Category:** Rails\
**Created:** [June 15, 2009, 12:57am UTC](https://www.ruby-forum.com/t/what-this-for/170252 "2009-06-15T00:57:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tivrfoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c4cdca/32.png) [@tivrfoa](https://www.ruby-forum.com/u/tivrfoa)\
**Post date:** [June 15, 2009, 12:57am UTC](https://www.ruby-forum.com/t/what-this-for/170252/1 "2009-06-15T00:57:39Z")

</div>

hello

what this “-” for?

thanks!

---

<div class="post-metadata">

**Author:** ![tivrfoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c4cdca/32.png) [@tivrfoa](https://www.ruby-forum.com/u/tivrfoa)\
**Post date:** [June 15, 2009, 1:41am UTC](https://www.ruby-forum.com/t/what-this-for/170252/2 "2009-06-15T01:41:30Z")

</div>

On Sun, Jun 14, 2009 at 3:54 PM, tivrfoa[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hello
> 
> what this “-” for?
> 
> thanks!

-%\> strips the trailing whitespace and newline.

\<%- strips leading whitespace but not newline.

So  
\<% if foo %\>  
bar  
\<% end %\>  
generates " \n bar\n \n" whereas  
\<%- if foo -%\>  
bar  
\<%- end -%\>  
generates " bar\n"

This is especially useful in templates for plain-text emails.

jeremy

---

<div class="post-metadata">

**Author:** ![tivrfoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c4cdca/32.png) [@tivrfoa](https://www.ruby-forum.com/u/tivrfoa)\
**Post date:** [June 15, 2009, 2:21am UTC](https://www.ruby-forum.com/t/what-this-for/170252/3 "2009-06-15T02:21:50Z")

</div>

Thanks Jeremy! So it has no effect in html.erb files, i.e., in the  
views, right? I tested here and nothing changed.

Here is a page that maybe can help someone:  
[http://springyweb.com/documents/1](http://springyweb.com/documents/1)
