Class: ERBook::Template::Sandbox
- Inherits:
-
Object
- Object
- ERBook::Template::Sandbox
- Defined in:
- lib/erbook/template.rb
Overview
Environment for template evaluation.
Instance Method Summary collapse
-
#__block_content__(*block_args) ⇒ Object
Returns an array of things that the given block wants to append to the buffer.
Instance Method Details
#__block_content__(*block_args) ⇒ Object
Returns an array of things that the given block wants to append to the buffer. If the given block does not want to append to the buffer, then returns the result of invoking the given block inside an array.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/erbook/template.rb', line 100 def __block_content__ *block_args raise ArgumentError, 'block must be given' unless block_given? original = @buffer begin block_content = @buffer = [] return_value = yield(*block_args) # this appends content to @buffer ensure @buffer = original end if block_content.empty? [return_value] else block_content end end |