Module: Cell::ViewModel::Layout::External

Defined in:
lib/cell/layout.rb

Overview

Allows using a separate layout cell which will wrap the actual content. Use like cell(…, layout: Cell::Layout)

Note that still allows the ‘render layout: :application` option.

Constant Summary collapse

Render =

WARNING: THIS IS NOT FINAL API.

->(content, model, layout, options) do # WARNING: THIS IS NOT FINAL API.
  return content unless layout = layout # TODO: test when invoking cell without :layout.

  # DISCUSS: should we allow instances, too? we could cache the layout cell.
  layout.new(model, context: options[:context]).(&lambda { content })
end

Instance Method Summary collapse

Instance Method Details

#callObject



42
43
44
45
# File 'lib/cell/layout.rb', line 42

def call(*)
  content = super
  Render.(content, model, @options[:layout], @options)
end