Method: Merb::RenderMixin#throw_content
- Defined in:
- lib/merb-core/controller/mixins/render.rb
#throw_content(obj, string = nil, &block) ⇒ Object
Called in templates to store up content for later use. Takes a string and/or a block. First, the string is evaluated, and then the block is captured using the capture() helper provided by the template languages. The two are concatenated together.
Parameters
- obj<Object>
-
The key in the thrown_content hash.
- string<String>
-
Textual content. Defaults to nil.
- &block
-
A block to be evaluated and concatenated to string.
Raises
- ArgumentError
-
Neither string nor block given.
Example
throw_content(:foo, "Foo")
catch_content(:foo) #=> "Foo"
473 474 475 476 477 478 |
# File 'lib/merb-core/controller/mixins/render.rb', line 473 def throw_content(obj, string = nil, &block) unless string || block_given? raise ArgumentError, "You must pass a block or a string into throw_content" end @_caught_content[obj] = string.to_s << (block_given? ? capture(&block) : "") end |