# How to parse a .erb string and store the result on another string

**URL:** <https://www.ruby-forum.com/t/how-to-parse-a-erb-string-and-store-the-result-on-another-string/144478>\
**Category:** Rails\
**Created:** [July 30, 2008, 12:55am UTC](https://www.ruby-forum.com/t/how-to-parse-a-erb-string-and-store-the-result-on-another-string/144478 "2008-07-30T00:55:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andres](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@andres](https://www.ruby-forum.com/u/andres)\
**Post date:** [July 30, 2008, 12:55am UTC](https://www.ruby-forum.com/t/how-to-parse-a-erb-string-and-store-the-result-on-another-string/144478/1 "2008-07-30T00:55:59Z")

</div>

Hi

Before diving on the seas of find-out-your-self  
I though I’d venture a post.

given a string with valid .erb syntax such as

string=’\<% who=world %\> hello \<%= who %\>’

is there a way to parse it and obtain the result?

something like the imaginary method parse\_erb

string.parse\_erb  
=\> “hello world”

Anybody has a good idea on how to do this?

Thank you,

Andres

---

<div class="post-metadata">

**Author:** ![andres](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@andres](https://www.ruby-forum.com/u/andres)\
**Post date:** [July 30, 2008, 1:18am UTC](https://www.ruby-forum.com/t/how-to-parse-a-erb-string-and-store-the-result-on-another-string/144478/2 "2008-07-30T01:18:13Z")

</div>

On Tue, 2008-07-29 at 16:55 -0600, andres wrote:

> something like the imaginary method parse\_erb
> 
> string.parse\_erb  
> =\> “hello world”
> 
> Anybody has a good idea on how to do this?

don’t worry,  
looks a piece of cake  
[http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html](http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html)
