Module: Serve::ContentHelpers
- Included in:
- ViewHelpers
- Defined in:
- lib/serve/view_helpers.rb
Instance Method Summary (collapse)
- - (Object) capture(&block)
- - (Object) capture_erb(&block) (also: #capture_rhtml)
- - (Object) content_for(symbol, &block)
- - (Boolean) content_for?(symbol)
- - (Object) get_content_for(symbol = :content)
- - (Object) set_content_for(symbol, value)
Instance Method Details
- (Object) capture(&block)
68 69 70 71 72 73 74 75 |
# File 'lib/serve/view_helpers.rb', line 68 def capture(&block) capture_method = "capture_#{script_extension}" if respond_to? capture_method send capture_method, &block else raise "Capture not supported for `#{script_extension}' template (#{engine_name})" end end |
- (Object) capture_erb(&block) Also known as: capture_rhtml
58 59 60 61 62 63 64 65 |
# File 'lib/serve/view_helpers.rb', line 58 def capture_erb(&block) buffer = "" old_buffer, @out_var = @_out_var, buffer yield buffer ensure @out_var = old_buffer end |
- (Object) content_for(symbol, &block)
38 39 40 |
# File 'lib/serve/view_helpers.rb', line 38 def content_for(symbol, &block) set_content_for(symbol, capture(&block)) end |
- (Boolean) content_for?(symbol)
42 43 44 |
# File 'lib/serve/view_helpers.rb', line 42 def content_for?(symbol) !(get_content_for(symbol)).nil? end |
- (Object) get_content_for(symbol = :content)
46 47 48 49 50 51 52 |
# File 'lib/serve/view_helpers.rb', line 46 def get_content_for(symbol = :content) if symbol.to_s.intern == :content @content else instance_variable_get("@content_for_#{symbol}") end end |
- (Object) set_content_for(symbol, value)
54 55 56 |
# File 'lib/serve/view_helpers.rb', line 54 def set_content_for(symbol, value) instance_variable_set("@content_for_#{symbol}", value) end |