class TemplateLoader
Public Class Methods
new(client)
click to toggle source
Calls superclass method
# File lib/shot_mvc/template_loader.rb, line 18 def initialize(client) super(client) @type = 'template' end
Public Instance Methods
get(name)
click to toggle source
# File lib/shot_mvc/template_loader.rb, line 23 def get(name) if template_exists? name if full_path? name Template.new name else Template.new "./app/views/#{name}.erb" end else if @client.config['server']['Security']['VisualErrors'] then begin raise TemplateLoadException.new "Could not load #{name}. Verify it exists at app/views/#{name}.erb" rescue Exception => ex template = Template.new "#{gem_root}/app/views/view_not_found.erb" template.data = { :requested_view => name, :exception => ex } return template end else raise TemplateLoadException.new "Could not load #{name}. Verify it exists at app/views/#{name}.erb" end end end
Private Instance Methods
full_path?(view_name)
click to toggle source
# File lib/shot_mvc/template_loader.rb, line 51 def full_path?(view_name) File.exists? view_name end
gem_root()
click to toggle source
# File lib/shot_mvc/template_loader.rb, line 47 def gem_root Gem::Specification.find_by_name('shot_mvc').gem_dir end
template_exists?(view_name)
click to toggle source
# File lib/shot_mvc/template_loader.rb, line 55 def template_exists?(view_name) File.exists? view_name or File.exists? "app/views/#{view_name}.erb" end