Forum: Ruby on Rails Generating ERB directly from RoR code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47df9cfb356c3ee0523cc3571b169730?d=identicon&s=25 Kenneth McDonald (Guest)
on 2008-12-02 21:04
(Received via mailing list)
I have a situation where it would be useful to generate ERB directly
from Rails code, rather than taking it from a file. Is this possible?
If so, how would one go about it?

Thanks,
Ken McDonald
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-02 22:23
(Received via mailing list)
On Dec 2, 8:03 pm, Kenneth McDonald <kenneth.m.mcdon...@sbcglobal.net>
wrote:
> I have a situation where it would be useful to generate ERB directly  
> from Rails code, rather than taking it from a file. Is this possible?  
> If so, how would one go about it?
>
Well there's render :inline if you're in a controller or you can just
use erb directly

greeting = world
ERB.new("hello <%= greeting %>").result binding #=> "hello world"

Fred
This topic is locked and can not be replied to.