summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 10:48:57 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 10:48:57 (GMT)
commit9e52416cd304c648e7bf49f1e77c81cd5adac506 (patch)
tree193bed0099ad0599045619bd863c9f85ddbfb975 /lib
parente82f4195d49b730a48031738694391dbb3e41091 (diff)
erb: set variables from the command line
* bin/erb (ARGV.switch, ERB::Main#run): allow variables to be set from the command line. [ruby-core:65772] [Feature #10395] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/erb.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index 5c41c37..25654d6 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -797,7 +797,7 @@ class ERB
@safe_level = safe_level
compiler = make_compiler(trim_mode)
set_eoutvar(compiler, eoutvar)
- @src, @enc = *compiler.compile(str)
+ @src, @encoding = *compiler.compile(str)
@filename = nil
@lineno = 0
end
@@ -812,6 +812,9 @@ class ERB
# The Ruby code generated by ERB
attr_reader :src
+ # The encoding to eval
+ attr_reader :encoding
+
# The optional _filename_ argument passed to Kernel#eval when the ERB code
# is run
attr_accessor :filename
@@ -879,7 +882,7 @@ class ERB
# print MyClass.new.render('foo', 123)
def def_method(mod, methodname, fname='(ERB)')
src = self.src
- magic_comment = "#coding:#{@enc}\n"
+ magic_comment = "#coding:#{@encoding}\n"
mod.module_eval do
eval(magic_comment + "def #{methodname}\n" + src + "\nend\n", binding, fname, -2)
end