class Jekyll::ReadYamlPage

Public Instance Methods

read_yaml(base, name, opts = {}) click to toggle source
# File lib/jekyll-gallery-generator.rb, line 71
def read_yaml(base, name, opts = {})
  begin
    self.content = File.read(File.join(base.to_s, name.to_s), (site ? site.file_read_opts : {}).merge(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.to_s, name.to_s)}: #{e.message}"
  rescue Exception => e
    Jekyll.logger.warn "Error reading file #{File.join(base.to_s, name.to_s)}: #{e.message}"
  end

  self.data ||= {}
end