Class: Dryml::Railtie::PageTagResolver

Inherits:
ActionView::Resolver
  • Object
show all
Defined in:
lib/dryml/railtie/page_tag_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ PageTagResolver

Returns a new instance of PageTagResolver.



5
6
7
8
# File 'lib/dryml/railtie/page_tag_resolver.rb', line 5

def initialize(controller)
  @controller = controller
  super()
end

Instance Method Details

#find_templates(name, prefix, partial, details, outside_app_allowed = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dryml/railtie/page_tag_resolver.rb', line 10

def find_templates(name, prefix, partial, details, outside_app_allowed = false)
  tag_name = @controller.dryml_fallback_tag || name.dasherize + '-page'
  method_name = tag_name.to_s.gsub('-', '_')
  details[:virtual_path] = "#{prefix}/#{name}"
  if Dryml.empty_page_renderer(@controller.view_context).respond_to?(method_name)
    [ActionView::Template.new('', Dryml.page_tag_identifier(@controller.controller_path, tag_name),
                              Dryml::Railtie::TemplateHandler, details)]
  else
    []
  end
end