Sha256: faedcb91499bb1e39bdaa4a222385189f8d5a62b826a0e9a7b3a1999468f1d9f

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

module Octopress
  module Docs
    module Convertible
      include Jekyll::Convertible

      # Read the YAML frontmatter.
      #
      # base - The String path to the dir containing the file.
      # name - The String filename of the file.
      # opts - optional parameter to File.read, default at site configs
      #
      # Returns nothing.
      def read_yaml(base, name, opts = {})
        begin
          self.content = File.read(File.join(base, name),
                                   merged_file_read_opts(opts))
          if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
            self.content = $POSTMATCH
            self.data = SafeYAML.load($1)
          end
        rescue SyntaxError => e
          Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}"
        rescue Exception => e
          Jekyll.logger.warn "Error reading file #{File.join(base, name)}: #{e.message}"
        end

        self.data ||= {}
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octopress-docs-0.0.15 lib/octopress-docs/jekyll/convertible.rb
octopress-docs-0.0.14 lib/octopress-docs/jekyll/convertible.rb
octopress-docs-0.0.13 lib/octopress-docs/jekyll/convertible.rb
octopress-docs-0.0.12 lib/octopress-docs/jekyll/convertible.rb