Index: lib/erb.rb =================================================================== --- lib/erb.rb (revision 21686) +++ lib/erb.rb (working copy) @@ -847,10 +847,10 @@ module DefMethod public # define _methodname_ as instance method of current module, using ERB object or eRuby file - def def_erb_method(methodname, erb_or_fname) + def def_erb_method(methodname, erb_or_fname, safe_level=nil, trim_mode=nil, eoutvar='_erbout') if erb_or_fname.kind_of? String fname = erb_or_fname - erb = ERB.new(File.read(fname)) + erb = ERB.new(File.read(fname), safe_level, trim_mode, eoutvar) erb.def_method(self, methodname, fname) else erb = erb_or_fname Index: test/erb/trim_hello.erb =================================================================== --- test/erb/trim_hello.erb (revision 0) +++ test/erb/trim_hello.erb (revision 0) @@ -0,0 +1,4 @@ += hello +<%- 3.times do |n| -%> +* <%= n %> +<%- end -%> Index: test/erb/test_erb.rb =================================================================== --- test/erb/test_erb.rb (revision 21686) +++ test/erb/test_erb.rb (working copy) @@ -235,6 +235,11 @@ def_erb_method('hello_world', erb) end assert(klass.new.respond_to?('hello_world')) + + klass.module_eval do + def_erb_method('trim_hello', File.join(File.dirname(File.expand_path(__FILE__)), 'trim_hello.erb'), nil, '-') + end + assert(klass.new.respond_to?('trim_hello')) end def test_escape