Module: Trailblazer::Rails::Controller::Cell::Render
- Included in:
- Trailblazer::Rails::Controller::Cell
- Defined in:
- lib/trailblazer/rails/cell.rb
Instance Method Summary collapse
- #cell(constant, model, options = {}) ⇒ Object
-
#options_for_cell(_model, _options) ⇒ Object
Override this to customize what options are passed into the cell constructor.
- #render(cell = nil, options = {}, &block) ⇒ Object
- #render_cell(cell, options) ⇒ Object
Instance Method Details
#cell(constant, model, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/trailblazer/rails/cell.rb', line 20 def cell(constant, model, ={}) = .reverse_merge((model, )) super(constant, model, ) end |
#options_for_cell(_model, _options) ⇒ Object
Override this to customize what options are passed into the cell constructor. E.g. ‘Song::Cell::Layout`
28 29 30 |
# File 'lib/trailblazer/rails/cell.rb', line 28 def (_model, ) {} end |
#render(cell = nil, options = {}, &block) ⇒ Object
5 6 7 8 9 |
# File 'lib/trailblazer/rails/cell.rb', line 5 def render(cell = nil, = {}, *, &block) return super unless cell.kind_of?(::Cell::ViewModel) render_cell(cell, ) 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, ) = .reverse_merge(layout: true) # render the cell. content = cell.() render({html: content}.merge()) end |