Class: Jekyll::ReadYamlPage
- Inherits:
-
Page
- Object
- Page
- Jekyll::ReadYamlPage
show all
- Defined in:
- lib/jekyll-gallery-generator.rb
Instance Method Summary
collapse
Instance Method Details
#read_yaml(base, name, opts = {}) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# 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
|