Skip to content

Commit 04bb746

Browse files
[DOC] Enhanced doc for ERB.result (#73)
1 parent f4abab7 commit 04bb746

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lib/erb.rb

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,30 @@ def run(b=new_toplevel)
782782
print self.result(b)
783783
end
784784

785+
# :markup: markdown
786+
#
787+
# :call-seq:
788+
# result(binding = top_level) -> string
789+
#
790+
# Formats the string stored in template `self`;
791+
# returns the string result:
792+
#
793+
# - Each [expression tag][expression tags] is replaced by the value of the embedded expression.
794+
# - Each [execution tag][execution tags] is removed, and its embedded code is executed.
795+
# - Each [comment tag][comment tags] is removed.
796+
#
797+
# See examples at the links.
785798
#
786-
# Executes the generated ERB code to produce a completed template, returning
787-
# the results of that code.
799+
# Argument `binding` is a [binding object],
800+
# which should contain the bindings needed for all expression tags;
801+
# the default is #top_level.
802+
# See [Bindings][bindings].
788803
#
789-
# _b_ accepts a Binding object which is used to set the context of
790-
# code evaluation.
804+
# [binding object]: https://docs.ruby-lang.org/en/master/Binding.html
805+
# [bindings]: rdoc-ref:ERB@Bindings
806+
# [comment tags]: rdoc-ref:ERB@Comment+Tags
807+
# [execution tags]: rdoc-ref:ERB@Execution+Tags
808+
# [expression tags]: rdoc-ref:ERB@Expression+Tags
791809
#
792810
def result(b=new_toplevel)
793811
unless @_init.equal?(self.class.singleton_class)

0 commit comments

Comments
 (0)