Sha256: c5f227b4d8743d111557f49efd9b4c11cb3e034d78403b572f7914d5a2684976
Contents?: true
Size: 1.34 KB
Versions: 19
Compression:
Stored size: 1.34 KB
Contents
module Sitepress module Renderers # This would be the ideal way to render Sitepress resources, but there's a lot # of hackery involved in getting it to work properly. class Controller attr_reader :controller, :resource def initialize(resource, controller = SiteController) @controller = controller @resource = resource end def render renderer.render inline: resource.body, type: resource.handler, layout: resolve_layout, content_type: resource.mime_type.to_s end private def layout controller._layout end def has_layout_conditions? controller._layout_conditions? end def layout_conditions controller._layout_conditions end def renderer controller.renderer.new("PATH_INFO" => resource.request_path) end def resolve_layout return resource.data.fetch("layout") if resource.data.key? "layout" return layout unless has_layout_conditions? clause, formats = layout_conditions.first format = resource.format.to_s case clause when :only layout if formats.include? format when :except layout if formats.exclude? format end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems