Class: Sitepress::RenderingContext

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#resourceObject (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

#siteObject (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