aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erb.rb
diff options
context:
space:
mode:
authorzverok <zverok.offline@gmail.com>2019-10-26 09:34:14 +0300
committerTakashi Kokubun <takashikkbn@gmail.com>2019-10-26 10:24:20 -0700
commitf6f1377a4ec187579a7dd0249be1166b42bf668b (patch)
treebf2c5536ce503c09c0da850da93299d343a74f70 /lib/erb.rb
parentad9c7137282009bbecae8df8bd5a601311282d62 (diff)
downloadruby-f6f1377a4ec187579a7dd0249be1166b42bf668b.tar.gz
Update ERB docs
* Actualize Notes about other templating engines; * Document #location= method.
Diffstat (limited to 'lib/erb.rb')
-rw-r--r--lib/erb.rb29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index df9a1e910d..3f26c2ff30 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -248,15 +248,13 @@ require "cgi/util"
#
# == Notes
#
-# There are a variety of templating solutions available in various Ruby projects:
-# * ERB's big brother, eRuby, works the same but is written in C for speed;
-# * Amrita (smart at producing HTML/XML);
-# * cs/Template (written in C for speed);
-# * RDoc, distributed with Ruby, uses its own template engine, which can be reused elsewhere;
-# * and others; search {RubyGems.org}[https://rubygems.org/] or
-# {The Ruby Toolbox}[https://www.ruby-toolbox.com/].
+# There are a variety of templating solutions available in various Ruby projects.
+# For example, RDoc, distributed with Ruby, uses its own template engine, which
+# can be reused elsewhere.
#
-# Rails, the web application framework, uses ERB to create views.
+# Other popular engines could be found in the corresponding
+# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of
+# The Ruby Toolbox.
#
class ERB
Revision = '$Date:: $' # :nodoc: #'
@@ -861,6 +859,21 @@ class ERB
# is run
attr_accessor :lineno
+ #
+ # Sets optional filename and line number that will be used in ERB code
+ # evaluation and error reporting. See also #filename= and #lineno=
+ #
+ # 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
+ #
def location=((filename, lineno))
@filename = filename
@lineno = lineno if lineno