Class: Kojo::FrontMatterTemplate
- Inherits:
-
Object
- Object
- Kojo::FrontMatterTemplate
- 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
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(file) ⇒ FrontMatterTemplate
constructor
A new instance of FrontMatterTemplate.
- #render(additional_args = nil) ⇒ Object
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/kojo/front_matter_template.rb', line 9 def args @args end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/kojo/front_matter_template.rb', line 9 def file @file end |
#template ⇒ Object (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 |