Module: WelltreatStoreFramework::HamlRenderer::Partial

Extended by:
ActiveSupport::Concern
Included in:
Context
Defined in:
lib/welltreat_store_framework/haml_renderer/partial.rb

Instance Method Summary collapse

Instance Method Details

#partial(template, variables = { }) ⇒ Object

Render partial template

template - Template file name
           By default look for relative path to current action path
           Otherwise check by relative path to views path

variables - Define local variables

Return string content



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/welltreat_store_framework/haml_renderer/partial.rb', line 14

def partial(template, variables = { })
  _template_key = [
      self.response.controller_name,
      self.response.layout.to_s,
      self.response.template.to_s,
      template.to_s
  ].join('_')
  _file = self.app._full_partial_template_path(self.response, template)

  # Set local variables
  variables.each { |k, v| self.set_local(k, v) } if variables.present?

  # Render partial
  self.app._singleton_haml_instance(_template_key, _file).render(self)
end