Class: TemplateLoader

Inherits:
Loader
  • Object
show all
Defined in:
lib/shot_mvc/template_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TemplateLoader

Returns a new instance of TemplateLoader.



18
19
20
21
# File 'lib/shot_mvc/template_loader.rb', line 18

def initialize(client)
  super(client)
  @type = 'template'
end

Instance Method Details

#get(name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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 "./application/views/#{name}.erb"
    end
  else
    if @client.config['server']['Security']['VisualErrors'] then
      begin
        raise TemplateLoadException.new "Could not load #{name}. Verify it exists at application/views/#{name}.erb"
      rescue Exception => ex
        template = Template.new "#{gem_root}/application/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 application/views/#{name}.erb"
    end
  end
end