Sha256: c64183c473d53e7e67e75eb1485d6f2438d3dbc967de2c66f76f0e51696a835f

Contents?: true

Size: 409 Bytes

Versions: 2

Compression:

Stored size: 409 Bytes

Contents

module Brief
  class Document
    module FrontMatter
      extend ActiveSupport::Concern

      def frontmatter
        @frontmatter || load_frontmatter
      end

      protected

      def load_frontmatter
        if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
          self.content = content[($1.size + $2.size)..-1]
          @frontmatter = YAML.load($1).to_mash
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brief-1.1.0 lib/brief/document/front_matter.rb
brief-1.0.0 lib/brief/document/front_matter.rb