# Replacing ERB with Erubis

**URL:** <https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973>\
**Category:** Rails\
**Created:** [April 3, 2007, 2:50pm UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973 "2007-04-03T14:50:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [April 3, 2007, 2:50pm UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973/1 "2007-04-03T14:50:26Z")

</div>

Hey guys,

I’ve been hearing a lot about erubis: [http://www.kuwata-lab.com/erubis/](http://www.kuwata-lab.com/erubis/)  
Especially about how much faster it is than straight ERB.

In their Ruby on Rails support docs:  
[http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails](http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails)  
They state that with a few added lines to your environment.rb it will  
replace ERB completely.

I’m wondering if anyone has done this in an existing application and  
if there are any existing ERB area’s this might break. I’d also like  
to hear anyone’s experience with Erubis in general. Thanks.

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [April 3, 2007, 3:21pm UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973/2 "2007-04-03T15:21:33Z")

</div>

On Apr 3, 2007, at 8:49 AM, Marston A. wrote:

> if there are any existing ERB area’s this might break. I’d also like  
> to hear anyone’s experience with Erubis in general. Thanks.

I wrote up some notes on my experiences a couple of months ago:

> **[Speeding up Rails with erubis](https://jystewart.net/2007/02/13/speeding-up-rails-with-erubis/)**
>
> However much we buy into the adage that hardware is cheaper than developers, we all still need to make our code as responsive as possible. We tune the database, we refactor our code, and try to fin…

As I understand it the compatibility issues that were a problem  
earlier on are now resolved. I know I’ve not had any problems.

James.

–  
James S.  
Play: [http://james.anthropiccollective.org](http://james.anthropiccollective.org)  
Work: [http://jystewart.net/process/](http://jystewart.net/process/)

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [April 4, 2007, 9:06am UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973/3 "2007-04-04T09:06:50Z")

</div>

James,

Thanks, I’ll check out your writeup. Overall this looks like a good  
drop-in solution (assuming those issues were fixed). Can’t beat a 3x  
speed increase! 🙂

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [April 4, 2007, 3:03pm UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973/4 "2007-04-04T15:03:12Z")

</div>

Curious about the proposed patch: How does moving object instantiation  
into  
a separate method increase speed? Unless I’m actually blind, the patch  
on  
this page  
([http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails](http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails))  
would do nothing for increasing speed.

Is there something monkey patched in that take advantage of this change?

Jason

---

<div class="post-metadata">

**Author:** ![marstoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@marstoni](https://www.ruby-forum.com/u/marstoni)\
**Post date:** [April 4, 2007, 3:18pm UTC](https://www.ruby-forum.com/t/replacing-erb-with-erubis/90973/5 "2007-04-04T15:18:56Z")

</div>

Just checked out erubis. The newest version does the patch for you  
(check  
out rails\_helper.rb).
