Class: Sitepress::Parsers::Frontmatter
- Defined in:
- lib/sitepress/parsers/frontmatter.rb
Overview
TODO: Redo this to use File readline and pos to perform faster
Constant Summary collapse
- DELIMITER =
"---".freeze
- NEWLINE =
/\r\n?|\n/.freeze
- PATTERN =
/\A(#{DELIMITER}#{NEWLINE}(.+?)#{NEWLINE}#{DELIMITER}#{NEWLINE}*)?(.+)\Z/m
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(content) ⇒ Frontmatter
constructor
A new instance of Frontmatter.
Constructor Details
#initialize(content) ⇒ Frontmatter
Returns a new instance of Frontmatter.
14 15 16 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 14 def initialize(content) _, @data, @body = content.match(PATTERN).captures end |
Instance Method Details
#data ⇒ Object
18 19 20 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 18 def data @data ? YAML.load(@data) : {} end |