Skip to content

Commit f72d0f3

Browse files
BurdetteLamarmatzbot
authored andcommitted
[ruby/erb] [DOC] Doc for ERB#set_eoutvar
ruby/erb@cb4911f5f0
1 parent 49dc988 commit f72d0f3

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

lib/erb.rb

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,35 @@ def location=((filename, lineno))
974974
@lineno = lineno if lineno
975975
end
976976

977+
# :markup: markdown
978+
#
979+
# :call-seq:
980+
# set_eoutvar(compiler, eoutvar = '_erbout') -> [eoutvar]
977981
#
978-
# Can be used to set _eoutvar_ as described in ERB::new. It's probably
979-
# easier to just use the constructor though, since calling this method
980-
# requires the setup of an ERB _compiler_ object.
982+
# Sets the `eoutvar` value in the ERB::Compiler object `compiler`;
983+
# returns a 1-element array containing the value of `eoutvar`:
984+
#
985+
# ```
986+
# template = ERB.new('')
987+
# compiler = template.make_compiler(nil)
988+
# pp compiler
989+
# #<ERB::Compiler:0x000001cff8a9aa00
990+
# @insert_cmd="print",
991+
# @percent=false,
992+
# @post_cmd=[],
993+
# @pre_cmd=[],
994+
# @put_cmd="print",
995+
# @trim_mode=nil>
996+
# template.set_eoutvar(compiler, '_foo') # => ["_foo"]
997+
# pp compiler
998+
# #<ERB::Compiler:0x000001cff8a9aa00
999+
# @insert_cmd="_foo.<<",
1000+
# @percent=false,
1001+
# @post_cmd=["_foo"],
1002+
# @pre_cmd=["_foo = +''"],
1003+
# @put_cmd="_foo.<<",
1004+
# @trim_mode=nil>
1005+
# ```
9811006
#
9821007
def set_eoutvar(compiler, eoutvar = '_erbout')
9831008
compiler.put_cmd = "#{eoutvar}.<<"

0 commit comments

Comments
 (0)