Class: Locomotive::Mounter::Utils::YAMLFrontMattersTemplate
- Inherits:
-
Object
- Object
- Locomotive::Mounter::Utils::YAMLFrontMattersTemplate
- Defined in:
- lib/locomotive/mounter/utils/yaml_front_matters_template.rb
Overview
YAML Front-matters for HAML/Liquid templates
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#line_offset ⇒ Object
Returns the value of attribute line_offset.
-
#raw_source ⇒ Object
Returns the value of attribute raw_source.
Instance Method Summary collapse
-
#initialize(filepath) ⇒ YAMLFrontMattersTemplate
constructor
A new instance of YAMLFrontMattersTemplate.
- #source ⇒ Object
Constructor Details
#initialize(filepath) ⇒ YAMLFrontMattersTemplate
Returns a new instance of YAMLFrontMattersTemplate.
10 11 12 13 14 15 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 10 def initialize(filepath) self.filepath = filepath self.line_offset = 0 self.fetch_attributes_and_raw_source(File.read(self.filepath)) end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 8 def attributes @attributes end |
#filepath ⇒ Object
Returns the value of attribute filepath.
8 9 10 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 8 def filepath @filepath end |
#line_offset ⇒ Object
Returns the value of attribute line_offset.
8 9 10 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 8 def line_offset @line_offset end |
#raw_source ⇒ Object
Returns the value of attribute raw_source.
8 9 10 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 8 def raw_source @raw_source end |
Instance Method Details
#source ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/mounter/utils/yaml_front_matters_template.rb', line 17 def source return @source if @source @source = if self.filepath.ends_with?('.haml') Haml::Engine.new(self.raw_source).render else self.raw_source end end |