Class: Jekyll::VersionedFiles::FrontMatter
- Inherits:
-
Object
- Object
- Jekyll::VersionedFiles::FrontMatter
- Defined in:
- lib/jekyll/versioned_files/frontmatter.rb
Constant Summary collapse
- FRONTMATTER_REGEXP =
%r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#data ⇒ Object
Returns the value of attribute data.
-
#frontmatter ⇒ Object
Returns the value of attribute frontmatter.
-
#new_data ⇒ Object
Returns the value of attribute new_data.
Instance Method Summary collapse
-
#create ⇒ Object
Creates a new Front matter block.
-
#initialize(new_data) ⇒ FrontMatter
constructor
Initialize FileDocument.
-
#update ⇒ Object
Updates the content’s Front Matter.
Constructor Details
#initialize(new_data) ⇒ FrontMatter
Initialize FileDocument.
Returns nothing.
18 19 20 21 22 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 18 def initialize(new_data) @data = {} @fm_mods = VersionedFiles.frontmatter @new_data = new_data || {} end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 4 def content @content end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 4 def data @data end |
#frontmatter ⇒ Object
Returns the value of attribute frontmatter.
4 5 6 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 4 def frontmatter @frontmatter end |
#new_data ⇒ Object
Returns the value of attribute new_data.
4 5 6 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 4 def new_data @new_data end |
Instance Method Details
#create ⇒ Object
Creates a new Front matter block
Returns content with updated Front Matter
36 37 38 39 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 36 def create merge_data to_frontmatter end |
#update ⇒ Object
Updates the content’s Front Matter
Returns content with updated Front Matter
27 28 29 30 31 |
# File 'lib/jekyll/versioned_files/frontmatter.rb', line 27 def update mod_key("permalink") if data.has_key?("permalink") && @fm_mods["permalink"] merge_data @content.sub!(FRONTMATTER_REGEXP, to_frontmatter) || @content end |