Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
ERB#location=
location=((filename, lineno))
lib/erb.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/erb.rb, line 394
def location=((filename, lineno))
@filename = filename
@lineno = lineno if lineno
end
Sets optional filename and line number that will be used in ERB code evaluation and error reporting. See also filename= and lineno=
Example
erb = ERB.new('<%= some_x %>') erb.render # undefined local variable or method `some_x' # from (erb):1 erb.location = ['file.erb', 3] # All subsequent error reporting would use new location erb.render # undefined local variable or method `some_x' # from file.erb:4
See also
#def_module
#make_compiler
#def_method
#new_toplevel
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0