Class: Suricate::TemplateRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/suricate/template/template_repository.rb

Defined Under Namespace

Classes: TemplateNotFound

Constant Summary collapse

SUPPORTED_FORMATS =
%w(html txt).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ TemplateRepository

Returns a new instance of TemplateRepository.



9
10
11
# File 'lib/suricate/template/template_repository.rb', line 9

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/suricate/template/template_repository.rb', line 6

def path
  @path
end

Instance Method Details

#find(name) ⇒ Object



23
24
25
26
27
28
# File 'lib/suricate/template/template_repository.rb', line 23

def find(name)
  path = find_full_path(name) or
    raise TemplateNotFound.new("#{name} can't be found in #{@path}")

  Template.new(path)
end

#find_page(name) ⇒ Object



18
19
20
21
# File 'lib/suricate/template/template_repository.rb', line 18

def find_page(name)
  path = File.join('pages', name)
  find(path)
end

#find_widget(name) ⇒ Object



13
14
15
16
# File 'lib/suricate/template/template_repository.rb', line 13

def find_widget(name)
  path = File.join('widgets', name)
  find(path)
end