class Suricate::TemplateRepository
Constants
- SUPPORTED_FORMATS
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/suricate/template/template_repository.rb, line 9 def initialize(path) @path = path end
Public Instance Methods
find(name)
click to toggle source
# 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)
click to toggle source
# File lib/suricate/template/template_repository.rb, line 18 def find_page(name) path = File.join('pages', name) find(path) end
find_widget(name)
click to toggle source
# File lib/suricate/template/template_repository.rb, line 13 def find_widget(name) path = File.join('widgets', name) find(path) end
Private Instance Methods
find_full_path(name)
click to toggle source
# File lib/suricate/template/template_repository.rb, line 31 def find_full_path(name) base_path = File.join(@path, name) if File.exists?(base_path) base_path else possible_paths = SUPPORTED_FORMATS.map { |format| base_path + ".#{format}" } possible_paths.find { |path| File.exists?(path) } end end