Generating ERB directly from RoR code

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

On Dec 2, 8:03 pm, Kenneth McDonald [email protected]
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs