Skip to content
Nick Sutterer edited this page Aug 27, 2021 · 8 revisions

Questions

Layout class method

Is anyone using Cell::layout to set a cell-wide layout?

class Cell::Form < Trailblazer::Cell
  layout :bla

Cell instance

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 %>

Design

Layout

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()}

Ad-hoc views

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

Hook to customize final rendering

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