Stopping ruby from escaping characters

I’m trying to open a file with variables encased inside the
interpolation operator, but when I open the file it escapes the #
character. I try and gsub it but it reinserts the escape character
anyway. Is there anyway to make ruby ignore the # character so I can
use variables in files?

On Sat, Aug 28, 2010 at 2:40 PM, Shef [email protected] wrote:

I’m trying to open a file with variables encased inside the
interpolation operator, but when I open the file it escapes the #
character. I try and gsub it but it reinserts the escape character
anyway. Is there anyway to make ruby ignore the # character so I can
use variables in files?

When you read it in, it is a String, not code being interpreted.

Rather than trying to interpolate data in a file, try using ERB.

Here is the example from the docs written using a file rather than
string:

Here is a quick hopefully straightforward primer:
http://github.com/JoshCheek/JoshsRubyKickstart/blob/master/cheatsheets/erb-embedded_ruby.rb