Module: Cell::Rails::Capture::ContentForExtension

Defined in:
lib/cells_capture.rb

Instance Method Summary collapse

Instance Method Details

#content_for(name, content = nil, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cells_capture.rb', line 23

def content_for(name, content=nil, &block)
  # this resembles rails' own #content_for INTENTIONALLY. Due to some internal rails-thing we have to call #capture on the cell's view, otherwise,
  # rails wouldn't suppress the captured output. uncomment next line to provoke.
  #cnt = @tpl.capture(&block)

  if content || block_given?
    content = capture(&block) if block_given?
    @global_tpl.view_flow.append(name, content) if content
    nil
  else
    @view_flow.get(name)
  end
# i would love to simply do this:
# TODO: refactor rails helper.
#@tpl.content_for(*args, &block)
#nil
end