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



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/cell/view_model.rb', line 158

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



170
171
172
173
174
# File 'lib/cell/view_model.rb', line 170

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