module Cell::ViewModel::Layout
Set the layout per cell class. This is used in render calls. Gets inherited to subclasses.
Public Class Methods
included(base)
click to toggle source
# File lib/cell/layout.rb, line 5 def self.included(base) base.extend ClassMethods base.inheritable_attr :layout_name end
Private Instance Methods
process_options!(options)
click to toggle source
Calls superclass method
# File lib/cell/layout.rb, line 17 def process_options!(options) options[:layout] ||= self.class.layout_name super end
render_layout(name, options, content)
click to toggle source
# File lib/cell/layout.rb, line 32 def render_layout(name, options, content) template = find_template(options.merge view: name) # we could also allow a different layout engine, etc. render_template(template, options) { content } end
render_to_string(options, &block)
click to toggle source
Calls superclass method
# File lib/cell/layout.rb, line 22 def render_to_string(options, &block) with_layout(options, super) end
with_layout(options, content)
click to toggle source
# File lib/cell/layout.rb, line 26 def with_layout(options, content) return content unless layout = options[:layout] render_layout(layout, options, content) end