Class: Locomotive::PartialsCell

Inherits:
Cell::Rails
  • Object
show all
Defined in:
app/cells/locomotive/partials_cell.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_template(namespace, name) ⇒ Object



5
6
7
8
9
# File 'app/cells/locomotive/partials_cell.rb', line 5

def self.add_template(namespace, name)
  self.templates ||= {}
  self.templates[namespace] ||= []
  self.templates[namespace] << name
end

Instance Method Details

#display(namespace, locals = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/cells/locomotive/partials_cell.rb', line 11

def display(namespace, locals = {})
  return unless self.class.templates && self.class.templates[namespace].present?

  locals.each_pair do |k,v|
    instance_variable_set("@#{k}", v)
  end

  self.class.templates[namespace].map { |template| render view: template }.join.html_safe
end