Class: Sitepress::RenderingContext
- Inherits:
-
Object
- Object
- Sitepress::RenderingContext
- Defined in:
- lib/sitepress/rendering_context.rb
Overview
TODO: We’re starting to get too many rendering contexts … and this won’t quite fit in with the Tilt rendering context. We’ll want to merge this and support ‘capture` so that we can get `wrap_layout` working.
Instance Attribute Summary collapse
-
#resource ⇒ Object
(also: #current_page)
readonly
Returns the value of attribute resource.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(resource:, site:) ⇒ RenderingContext
constructor
A new instance of RenderingContext.
- #render(layout: nil, locals: {}, &block) ⇒ Object
Constructor Details
#initialize(resource:, site:) ⇒ RenderingContext
Returns a new instance of RenderingContext.
9 10 11 12 13 14 |
# File 'lib/sitepress/rendering_context.rb', line 9 def initialize(resource:, site:) @resource = resource @site = site # TODO: Remove this from RenderingContext ... it should build load_helpers end |
Instance Attribute Details
#resource ⇒ Object (readonly) Also known as: current_page
Returns the value of attribute resource.
6 7 8 |
# File 'lib/sitepress/rendering_context.rb', line 6 def resource @resource end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/sitepress/rendering_context.rb', line 6 def site @site end |
Instance Method Details
#render(layout: nil, locals: {}, &block) ⇒ Object
16 17 18 19 |
# File 'lib/sitepress/rendering_context.rb', line 16 def render(layout: nil, locals: {}, &block) layout ||= resource.data["layout"] render_with_layout(layout) { renderer.render(self, **locals, &block) } end |