Module: Cell::ViewModel::TemplateFor

Included in:
Cell::ViewModel
Defined in:
lib/cell/view_model.rb

Instance Method Summary collapse

Instance Method Details

#find_template(options) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/cell/view_model.rb', line 179

def find_template(options)
  template_options = template_options_for(options) # imported by Erb, Haml, etc.
  # required options: :template_class, :suffix. everything else is passed to the template implementation.

  view      = options[:view]
  prefixes  = options[:prefixes]
  suffix    = template_options.delete(:suffix)
  view      = "#{view}.#{suffix}"

  template_for(prefixes, view, template_options) or raise TemplateMissingError.new(prefixes, view)
end

#template_for(prefixes, view, options) ⇒ Object



191
192
193
194
195
# File 'lib/cell/view_model.rb', line 191

def template_for(prefixes, view, options)
  # we could also pass _prefixes when creating class.templates, because prefixes are never gonna change per instance. not too sure if i'm just assuming this or if people need that.
  # Note: options here is the template-relevant options, only.
  self.class.templates[prefixes, view, options]
end