Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions lib/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,30 @@ def run(b=new_toplevel)
print self.result(b)
end

# :markup: markdown
#
# :call-seq:
# result(binding = top_level) -> string
#
# Formats the string stored in template `self`;
# returns the string result:
#
# - Each [expression tag][expression tags] is replaced by the value of the embedded expression.
# - Each [execution tag][execution tags] is removed, and its embedded code is executed.
# - Each [comment tag][comment tags] is removed.
#
# See examples at the links.
#
# Executes the generated ERB code to produce a completed template, returning
# the results of that code.
# Argument `binding` is a [binding object],
# which should contain the bindings needed for all expression tags;
# the default is #top_level.
# See [Bindings][bindings].
#
# _b_ accepts a Binding object which is used to set the context of
# code evaluation.
# [binding object]: https://docs.ruby-lang.org/en/master/Binding.html
# [bindings]: rdoc-ref:ERB@Bindings
# [comment tags]: rdoc-ref:ERB@Comment+Tags
# [execution tags]: rdoc-ref:ERB@Execution+Tags
# [expression tags]: rdoc-ref:ERB@Expression+Tags
#
def result(b=new_toplevel)
unless @_init.equal?(self.class.singleton_class)
Expand Down