class PhantomProxy::TemplateRenderer
Public Class Methods
create(binding_)
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 13 def self.create(binding_) (PhantomProxy.respond_to?(:env) && PhantomProxy.env == :production) ? TemplateRenderer.new(binding_) : ReloadTemplateRenderer.new(binding_) end
new(controller_binding_)
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 17 def initialize(controller_binding_) @controller_binding=controller_binding_ end
Public Instance Methods
render(template_name, bind=nil)
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 21 def render(template_name, bind=nil) template(template_name).result(bind||controller_binding) end
Private Instance Methods
controller_binding()
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 27 def controller_binding @controller_binding end
template(template_name)
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 31 def template(template_name) begin templates[template_name]||=::ERB.new(File.read(PhantomProxy.root.join("views", "#{template_name}.erb"))) rescue Errno::ENOENT => e templates[template_name]||=::ERB.new(File.read(PhantomProxy.root_gem.join("templates/views", "#{template_name}.erb"))) end end
templates()
click to toggle source
# File lib/phantom_proxy/helper/template_renderer.rb, line 39 def templates @templates||={} end