Class: Sitepress::Renderers::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/sitepress/renderers/controller.rb

Overview

This would be the ideal way to render Sitepress resources, but there’s a lot of hackery involved in getting it to work properly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, controller = SiteController) ⇒ Controller

Returns a new instance of Controller.



8
9
10
11
# File 'lib/sitepress/renderers/controller.rb', line 8

def initialize(resource, controller = SiteController)
  @controller = controller
  @resource = resource
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



6
7
8
# File 'lib/sitepress/renderers/controller.rb', line 6

def controller
  @controller
end

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'lib/sitepress/renderers/controller.rb', line 6

def resource
  @resource
end

Instance Method Details

#renderObject



13
14
15
16
17
18
# File 'lib/sitepress/renderers/controller.rb', line 13

def render
  renderer.render inline: resource.body,
    type: resource.handler,
    layout: resolve_layout,
    content_type: resource.mime_type.to_s
end