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 = nil, 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 = nil, options = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/trailblazer/rails/cell.rb', line 18 def cell(constant, model=nil, ={}) = .reverse_merge((model, )) super(constant, model, ) # From cells-rails gem. end |
#options_for_cell(_model, _options) ⇒ Object
Override this to customize what options are passed into the cell constructor. E.g. ‘Song::Cell::Layout`
26 27 28 |
# File 'lib/trailblazer/rails/cell.rb', line 26 def (_model, ) {} end |
#render(cell = nil, options = {}, &block) ⇒ Object
3 4 5 6 7 |
# File 'lib/trailblazer/rails/cell.rb', line 3 def render(cell = nil, = {}, *, &block) return super unless cell.kind_of?(::Cell::ViewModel) render_cell(cell, ) end |
#render_cell(cell, options) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/trailblazer/rails/cell.rb', line 9 def render_cell(cell, ) = .reverse_merge(layout: true) # render the cell. content = cell.() render({html: content}.merge()) end |