Class: Jekyll::ReadYamlPage

Inherits:
Page
  • Object
show all
Defined in:
lib/jekyll/ReadYamlPage.rb

Direct Known Subclasses

FDroidBrowsingPage, FDroidPackageDetailPage

Instance Method Summary collapse

Instance Method Details

#read_yaml(base, name, opts = {}) ⇒ Object

We need do define it ourself because the templates are in the plugin’s directory



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jekyll/ReadYamlPage.rb', line 23

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