Module | Webby::Helpers::CaptureHelper |
In: |
lib/webby/helpers/capture_helper.rb
|
Based on code from Rails and Merb.
Provides direct acccess to the ERB buffer in the conext of the binding.
the_binding<Binding>: | The binding to pass to the buffer. |
The current ERB output buffer.
This method is used to capture content from an ERB filter evaluation. It is useful to helpers that need to process chunks of data during ERB filter processing.
*args: | Arguments to pass to the block. |
&block: | The ERB block to call. |
String: | The output of the block. |
Capture being used in an ERB page:
<% @foo = capture_erb do %> <p>Some Foo content!</p> <% end %>
This method is used to concatenate content into the ERB output buffer. It is usefule to helpers that need to insert transformed text back into the ERB output buffer.
string<String>: | The string to insert into the ERB output. |
the_binding<Binding>: | The binding to pass to the buffer. |
Called in pages and partials 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.
Content is retrieved by calling the method without a string or a block.
obj<Object>: | The key in the conetnt_for hash. |
string<String>: | Textual content. Defaults to nil. |
&block: | A block to be evaluated and concatenated to string. |
Any content associated with the key (or nil).
content_for(:foo, "Foo") content_for(:foo) #=> "Foo" content_for(:foo, "Bar") content_for(:foo) #=> "FooBar"
Returns true if there is content for the given key. Otherwise returns false.
obj<Object>: | The key in the conetnt_for hash. |
content_for(:foo, "Foo") content_for?(:foo) #=> true content_for?(:bar) #=> false
Deletes any content associated with the given object in the content_for hash.
obj<Object>: | The key in the conetnt_for hash. |
Any content associated with the key (or nil).
content_for(:foo, "Foo") content_for?(:foo) #=> true delete_content_for(:foo) content_for?(:foo) #=> false