-
Notifications
You must be signed in to change notification settings - Fork 235
Cells 5 Design
Nick Sutterer edited this page Aug 27, 2021
·
8 revisions
Is anyone using Cell::layout
to set a cell-wide layout?
class Cell::Form < Trailblazer::Cell
layout :bla
Do we really need the cell instance? I envision the public API to be cell(...)
and that's it.
Is anyone using cell instances and passing down the cells in nested setups, eg
Email: <%= user_cell.email %>
Current way
Cell.new(..., layout: Layout::Cell)
People have to override Controller#cell
.
def cell(cell_class, model, options={})
super(cell_class, model, options.merge(layout: Layout::Cell::Authentication)) # FIXME: this interface sucks.
end # FIXME
We need to be able to configure the layout at call-time, too (or only there). Otherwise, it's very clumsy to add a controller-wide layout.
cell = Cell.new(layout: ..) # happens in cell(...)
cell.(we need layout here) # happens in {render cell()}
Currently, when you want to evaluate a ERB view passed as a string, this is how it's done (and it sucks).
class Final < Cell::ViewModel
def show(html:, **locals)
render view: html, locals: {**locals}
end
def find_template(view:, **, &block)
template = Tilt::ERBTemplate.new { view }
end
end
When you want to parse a rendered markdown view into HTML.
def render_layout(name, options, content)
content = Kramdown::Document.new(content).to_html
super(name, options, content)
end
After rendering a cell, it would be cool to have some result/return object or at least an array with public content? (not sure how to do it)
html = cell.(:show, snippet: snippet_name, path: @path)
headers = cell.instance_variable_get(:@headers)