Module: Pancake::Mixins::Render::ViewContext::ContentInheritance

Included in:
Pancake::Mixins::Render::ViewContext
Defined in:
lib/pancake/mixins/render/render.rb

Overview

Capture

Defined Under Namespace

Classes: Helper

Instance Method Summary collapse

Instance Method Details

#content_block(label = nil, &block) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/pancake/mixins/render/render.rb', line 123

def content_block(label = nil, &block)
  return self if label.nil?
  current_label = @_inherit_helper.current_label
  @_inherit_helper.current_label = label
  capture_method = ViewContext.capture_method_for(_current_renderer)
  @_inherit_helper.blocks[label] << [block, capture_method]
  if @_inherit_helper.inherits_from.nil?
    result = _capture_content_block(label)
    send(ViewContext.concat_method_for(_current_renderer), result)
  end
  @_inherit_helper.current_label = current_label
end

#inherits_from(name_or_template) ⇒ Object



119
120
121
# File 'lib/pancake/mixins/render/render.rb', line 119

def inherits_from(name_or_template)
  @_inherit_helper.inherits_from = name_or_template
end

#initialize(*args) ⇒ Object



114
115
116
117
# File 'lib/pancake/mixins/render/render.rb', line 114

def initialize(*args)
  super()
  @_inherit_helper = Helper.new
end

#superObject



136
137
138
139
140
141
# File 'lib/pancake/mixins/render/render.rb', line 136

def super
  @_inherit_helper.increment_super!
  result = _capture_content_block(@_inherit_helper.current_label)
  @_inherit_helper.decrement_super!
  result
end