Class: ExecJS::Rails::TemplateResolver

Inherits:
ActionView::Resolver
  • Object
show all
Defined in:
lib/execjs/rails/template_resolver.rb

Instance Method Summary collapse

Instance Method Details

#find_templates(name, prefix, partial, details) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/execjs/rails/template_resolver.rb', line 5

def find_templates(name, prefix, partial, details)
  path = "#{prefix}/#{name}"
  if details[:formats].include?(:html) && Renderer.has_view(path)
    [::ActionView::Template.new(
      "<%= execjs_render('#{path}') %>",
      "ExecJS - #{path}",
      ActionView::Template.registered_template_handler(:erb),
      {
        format: Mime[:erb],
        virtual_path: path
      }
    )]
  else
    []
  end
end