Class: Poirot::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/poirot/handler.rb

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/poirot/handler.rb', line 3

def self.call(template)
  view_path = "#{template.virtual_path}_view"
  abs_view_path = Rails.root.join('app/views', view_path)
  view_class = begin
    view_path.classify.constantize
  rescue NameError => e
    Rails.logger.info ">>> #{e}"
    Poirot::View
  end
  "#{view_class}.new(self, '#{template.source.gsub(/'/, "\\\\'")}').render.html_safe"
end