Class: Sitepress::Parsers::Frontmatter::Renderer
- Inherits:
-
Object
- Object
- Sitepress::Parsers::Frontmatter::Renderer
- Defined in:
- lib/sitepress/parsers/frontmatter.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #dump_yaml(data) ⇒ Object
-
#initialize(body:, data:) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(body:, data:) ⇒ Renderer
Returns a new instance of Renderer.
11 12 13 14 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 11 def initialize(body:, data:) @body = body @data = data end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 9 def body @body end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 9 def data @data end |
Instance Method Details
#dump_yaml(data) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 16 def dump_yaml(data) if YAML.respond_to? :safe_dump YAML.safe_dump data, permitted_classes: Frontmatter.permitted_classes else # Live dangerously, lol YAML.dump data end end |
#render ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/sitepress/parsers/frontmatter.rb', line 25 def render [ dump_yaml(Data.unmanage(data)), Frontmatter::DELIMITER, $/, $/, body ].join end |