Stopping ruby from escaping characters

S

Shef

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?
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

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:
http://gist.github.com/555505
Here is a quick hopefully straightforward primer:
http://github.com/JoshCheek/JoshsRubyKickstart/blob/master/cheatsheets/erb-embedded_ruby.rb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top