Module: Tipsy::Helpers::Capture
- Included in:
- Tipsy::Helpers, Rendering, Tag
- Defined in:
- lib/tipsy/helpers/capture.rb
Instance Method Summary collapse
- #capture(*args) ⇒ Object
- #content_for(name, content = nil, &block) ⇒ Object
- #content_for?(name) ⇒ Boolean
Instance Method Details
#capture(*args) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/tipsy/helpers/capture.rb', line 15 def capture(*args) buffer ||= "" @output_buffer, old_buffer = buffer, @output_buffer yield @output_buffer ensure @output_buffer = old_buffer end |
#content_for(name, content = nil, &block) ⇒ Object
5 6 7 8 9 |
# File 'lib/tipsy/helpers/capture.rb', line 5 def content_for(name, content = nil, &block) content ||= capture(&block) if block_given? instance_variable_set("@_#{name}", content) if content instance_variable_get("@_#{name}").to_s unless content end |
#content_for?(name) ⇒ Boolean
11 12 13 |
# File 'lib/tipsy/helpers/capture.rb', line 11 def content_for?(name) !instance_variable_get("@_#{name}").nil? end |