Class: Tilt::YamlFrontMattersHamlTemplate
- Inherits:
-
HamlTemplate
- Object
- HamlTemplate
- Tilt::YamlFrontMattersHamlTemplate
- Defined in:
- lib/locomotive/mounter/extensions/tilt/haml.rb
Overview
YAML Front-matters for HAML templates
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Attributes from YAML Front-matters header.
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Attributes from YAML Front-matters header
7 8 9 |
# File 'lib/locomotive/mounter/extensions/tilt/haml.rb', line 7 def attributes @attributes end |
Instance Method Details
#need_for_prerendering? ⇒ Boolean
9 10 11 |
# File 'lib/locomotive/mounter/extensions/tilt/haml.rb', line 9 def need_for_prerendering? true end |
#prepare ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/locomotive/mounter/extensions/tilt/haml.rb', line 13 def prepare if data =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)(.*)/m @attributes = YAML.load($1) @data = $3 end @data = @data.force_encoding('utf-8') begin super rescue Haml::SyntaxError => e # invalid haml so re-throw the exception but with keeping track of the attributes e.attributes = @attributes raise e end end |