class Bookbinder::Subnav::TemplateCreator

Attributes

fs[R]
html_doc_manipulator[R]
output_locations[R]

Public Class Methods

new(fs, output_locations) click to toggle source
# File lib/bookbinder/subnav/template_creator.rb, line 7
def initialize(fs, output_locations)
  @fs = fs
  @output_locations = output_locations
end

Public Instance Methods

create(navigation_entries, subnav_spec) click to toggle source
# File lib/bookbinder/subnav/template_creator.rb, line 12
def create(navigation_entries, subnav_spec)
  template_content = fs.read(template_path)
  links_template = ERB.new(fs.read(subnavs_path.join('_nav-links.erb')))

  populated_nav = ERB.new(template_content).result(LinkHolder.new(navigation_entries, links_template).get_binding)

  fs.write(text: populated_nav, to: subnav_destination(subnav_spec.subnav_name))
end

Private Instance Methods

filename(name) click to toggle source
# File lib/bookbinder/subnav/template_creator.rb, line 29
def filename(name)
  "#{name}.erb"
end
subnav_destination(name) click to toggle source
subnavs_path() click to toggle source
template_path() click to toggle source
# File lib/bookbinder/subnav/template_creator.rb, line 33
def template_path
  subnavs_path.join('_subnav_template.erb')
end