Module: Trailblazer::Rails::Controller::Cell::Render

Included in:
Trailblazer::Rails::Controller::Cell
Defined in:
lib/trailblazer/rails/cell.rb

Instance Method Summary collapse

Instance Method Details

#render(cell = nil, options = {}, &block) ⇒ Object



5
6
7
8
9
# File 'lib/trailblazer/rails/cell.rb', line 5

def render(cell = nil, options = {}, *, &block)
  return super unless cell.kind_of?(::Cell::ViewModel) # rubocop:disable Style/ClassCheck

  render_cell(cell, options)
end

#render_cell(cell, options) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/trailblazer/rails/cell.rb', line 11

def render_cell(cell, options)
  options = options.reverse_merge(layout: true)

  # render the cell.
  content = cell.()

  render({html: content}.merge(options))
end