Module: GollumRails::Meta
Instance Method Summary collapse
-
#has_yaml? ⇒ Boolean
Checks if this page has a Yaml part.
-
#html_without_yaml ⇒ Object
Gets the parsed html without the YAML part.
-
#meta ⇒ Object
Gets the parsed meta data.
-
#meta_title ⇒ Object
Example for meta data usage:.
-
#raw_meta ⇒ Object
Gets the pages raw Yaml header.
Instance Method Details
#has_yaml? ⇒ Boolean
Checks if this page has a Yaml part
Example YAML part:
title: “My Page”
YAML part is seperated from the rest by ‘—` before and after the content
Returns true or false
18 19 20 |
# File 'lib/gollum_rails/meta.rb', line 18 def has_yaml? !! end |
#html_without_yaml ⇒ Object
Gets the parsed html without the YAML part
Returns a string
52 53 54 |
# File 'lib/gollum_rails/meta.rb', line 52 def html_without_yaml gollum_page.markup_class.render(raw_data.tap{|s| s.slice!(.to_s)}) end |
#meta ⇒ Object
Gets the parsed meta data
Returns parsed YAML
34 35 36 37 38 |
# File 'lib/gollum_rails/meta.rb', line 34 def @meta ||= YAML.load() rescue Psych::SyntaxError => e {error: e} end |
#meta_title ⇒ Object
Example for meta data usage:
Gets the title from the meta data
Returns the title or nil
45 46 47 |
# File 'lib/gollum_rails/meta.rb', line 45 def ['title'] end |
#raw_meta ⇒ Object
Gets the pages raw Yaml header.
Returns either the raw yaml or an empty string
26 27 28 |
# File 'lib/gollum_rails/meta.rb', line 26 def raw_data.match(/^(?<headers>---\s*\n.*?\n?)^(---\s*$\n?)/m).to_s end |