class SitemapGenerator::Templates

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.

Constants

FILES

Public Class Methods

new(root = SitemapGenerator.root) click to toggle source
# File lib/sitemap_generator/templates.rb, line 23
def initialize(root = SitemapGenerator.root)
  @root = root
end

Public Instance Methods

template_path(template) click to toggle source

Return the full path to a template.

file template symbol e.g. :sitemap_sample

# File lib/sitemap_generator/templates.rb, line 30
def template_path(template)
  File.join(@root, 'templates', self.class::FILES[template])
end

Protected Instance Methods

read_template(template) click to toggle source

Read the template file and return its contents.

# File lib/sitemap_generator/templates.rb, line 37
def read_template(template)
  File.read(template_path(template))
end