Class: SitemapGenerator::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/sitemap_generator/templates.rb

Overview

Provide convenient access to template files. E.g.

SitemapGenerator.templates.sitemap_index

Lazy-load and cache for efficient access. Define an accessor method for each template file.

Constant Summary collapse

FILES =
{
  sitemap_sample: 'sitemap.rb'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(root = SitemapGenerator.root) ⇒ Templates

Returns a new instance of Templates.



25
26
27
# File 'lib/sitemap_generator/templates.rb', line 25

def initialize(root = SitemapGenerator.root)
  @root = root
end

Instance Method Details

#template_path(template) ⇒ Object

Return the full path to a template.

file template symbol e.g. :sitemap_sample



32
33
34
# File 'lib/sitemap_generator/templates.rb', line 32

def template_path(template)
  File.join(@root, 'templates', self.class::FILES[template])
end