Class: Jekyll::ReadYamlPage
- Inherits:
-
Page
- Object
- Page
- Jekyll::ReadYamlPage
- Defined in:
- lib/jekyll/ReadYamlPage.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#read_yaml(base, name, opts = {}) ⇒ Object
We need do define it ourself because the templates are in the plugin’s directory.
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.}" rescue Exception => e Jekyll.logger.warn "Error reading file #{File.join(base.to_s, name.to_s)}: #{e.}" end self.data ||= {} end |