# SHow do you suppress ERB newlines globally

**URL:** <https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015>\
**Category:** Rails\
**Created:** [February 20, 2006, 3:46pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015 "2006-02-20T15:46:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lindsay\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Lindsay\_B](https://www.ruby-forum.com/u/Lindsay_B)\
**Post date:** [February 20, 2006, 3:46pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015/1 "2006-02-20T15:46:01Z")

</div>

Is there a config flag to suppress the newline at the end of every ERB  
‘%\>’ tag, so it would not be necessary to type '-%\> each time?

---

<div class="post-metadata">

**Author:** ![Lindsay\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Lindsay\_B](https://www.ruby-forum.com/u/Lindsay_B)\
**Post date:** [February 20, 2006, 4:15pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015/2 "2006-02-20T16:15:03Z")

</div>

On Monday, February 20, 2006, at 3:46 PM, Lindsay B. wrote:

> Is there a config flag to suppress the newline at the end of every ERB  
> ‘%\>’ tag, so it would not be necessary to type '-%\> each time?

You would include this line in your environment.rb file:

ActionView::Base.erb\_trim\_mode = ‘\>’

---

<div class="post-metadata">

**Author:** ![Lindsay\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Lindsay\_B](https://www.ruby-forum.com/u/Lindsay_B)\
**Post date:** [February 20, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015/3 "2006-02-20T16:26:28Z")

</div>

> You would include this line in your environment.rb file:
> 
> ActionView::Base.erb\_trim\_mode = ‘\>’

I’ve added this line and restarted the server. I get the following  
error:

* * *

## Rendering within layouts/users Rendering users/profile ERROR: compiling \_run\_html\_users\_profile RAISED compile error public/…/config/…/app/views/users/profile.rhtml:31: parse error, unexpected tSTRING\_BEG, expecting kDO\_COND or ‘:’ or ‘\n’ or ‘;’

Line 31 is the first line of ERB ending in a ‘%\>’ tag to be rendered by  
the controller:

30: \<% for @box in @boxes -%\>  
31: \<%= render :partial =\> ‘boxes/box\_line’ %\>  
32: \<% end -%\>

---

<div class="post-metadata">

**Author:** ![Lindsay\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Lindsay\_B](https://www.ruby-forum.com/u/Lindsay_B)\
**Post date:** [February 20, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015/4 "2006-02-20T18:26:54Z")

</div>

Aha! Thanks!

---

<div class="post-metadata">

**Author:** ![Lindsay\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Lindsay\_B](https://www.ruby-forum.com/u/Lindsay_B)\
**Post date:** [February 20, 2006, 5:10pm UTC](https://www.ruby-forum.com/t/show-do-you-suppress-erb-newlines-globally/54015/5 "2006-02-20T17:10:23Z")

</div>

Now you have to delete all those ‘-’ characters throughout all your  
pages 🙂

## – Kent

> **[DATANOISE.COM](https://www.datanoise.com/)**
>
> DATANOISE.COM - Contact us for any business inquiries
