# Render Variable?

**URL:** <https://www.ruby-forum.com/t/render-variable/126927>\
**Category:** Rails\
**Created:** [January 23, 2008, 2:29pm UTC](https://www.ruby-forum.com/t/render-variable/126927 "2008-01-23T14:29:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [January 23, 2008, 2:29pm UTC](https://www.ruby-forum.com/t/render-variable/126927/1 "2008-01-23T14:29:05Z")

</div>

Hi All,  
I have a string variable that contains other ruby  
variables. I intend to render the string variable and replace the  
other ruby variables in it with their values.Is it possible?

To clarify my question, here is the same :-

@ruby\_variable = “Some value in the variable”

@variable\_to\_be\_rendered = “Some text @ruby\_variable”

After rendering(if thats possible, or some other function), I would  
get the value

“Some text Some value in the variable”

Regards,  
Mohit

---

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [January 23, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/render-variable/126927/2 "2008-01-23T14:59:52Z")

</div>

yes, you can use erb for that

[http://www.ruby-doc.org/core/classes/ERB.html](http://www.ruby-doc.org/core/classes/ERB.html)

> @variable\_to\_be\_rendered = “Some text @ruby\_variable”

would have to look like:

@variable\_to\_be\_rendered = “Some text \<%= @ruby\_variable %\>”

to do that

---

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [January 24, 2008, 7:25am UTC](https://www.ruby-forum.com/t/render-variable/126927/3 "2008-01-24T07:25:25Z")

</div>

Cool! It works like a charm :-).

Is there any thing similar in rails, rather than ruby?

On Jan 23, 6:59 pm, Thorsten M. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [January 24, 2008, 7:39am UTC](https://www.ruby-forum.com/t/render-variable/126927/4 "2008-01-24T07:39:26Z")

</div>

@var1 = “Hello”  
@var2 = “World #{@var1}”

On Jan 24, 2008 4:54 PM, mohit\_ranka [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Posted viahttp://www.ruby-forum.com/.

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
