Class: Kojo::FrontMatterTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/kojo/front_matter_template.rb

Overview

The FrontMatterTemplate class handles a single template file, that contains a YAML front matter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FrontMatterTemplate

Returns a new instance of FrontMatterTemplate.



11
12
13
# File 'lib/kojo/front_matter_template.rb', line 11

def initialize(file)
  @file = file
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



9
10
11
# File 'lib/kojo/front_matter_template.rb', line 9

def args
  @args
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/kojo/front_matter_template.rb', line 9

def file
  @file
end

#templateObject (readonly)

Returns the value of attribute template.



9
10
11
# File 'lib/kojo/front_matter_template.rb', line 9

def template
  @template
end

Instance Method Details

#render(additional_args = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/kojo/front_matter_template.rb', line 15

def render(additional_args = nil)
  additional_args ||= {}
  config, @template = read_file file

  config.each do |outfile, args|
    content = handle args.merge(additional_args)
    yield outfile, content
  end
end