Class: Machined::Processors::FrontMatterProcessor
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Machined::Processors::FrontMatterProcessor
- Defined in:
- lib/machined/processors/front_matter_processor.rb
Constant Summary collapse
- FRONT_MATTER_PARSER =
The Regexp that separates the YAML front matter from the content.
/ ( \A\s* # Beginning of file ^---\s*$\n* # Start YAML Block (.*?)\n* # YAML data ^---\s*$\n* # End YAML Block ) (.*)\Z # Rest of File /mx
Instance Method Summary collapse
-
#evaluate(context, locals = {}, &block) ⇒ Object
See ‘Tilt::Template#evaluate`.
-
#prepare ⇒ Object
See ‘Tilt::Template#prepare`.
Instance Method Details
#evaluate(context, locals = {}, &block) ⇒ Object
See ‘Tilt::Template#evaluate`.
24 25 26 27 28 29 30 31 32 |
# File 'lib/machined/processors/front_matter_processor.rb', line 24 def evaluate(context, locals = {}, &block) output = data if FRONT_MATTER_PARSER.match data locals = YAML.load $2 context.locals = locals if locals output = $3 end output end |
#prepare ⇒ Object
See ‘Tilt::Template#prepare`.
20 21 |
# File 'lib/machined/processors/front_matter_processor.rb', line 20 def prepare end |