Sha256: 60268b4cfe9b6851a44539efd21313cd30ee11df0e4b9d71a127d8bfe15e32d4

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 Bytes

Contents

module Edifice
  module Renderer
    def self.included(renderer)
      renderer.class_eval do
        def _template_renderer #:nodoc:
          @_template_renderer ||= Edifice::TemplateRenderer.new(@lookup_context)
        end
      end
    end
  end

  class TemplateRenderer < ActionView::TemplateRenderer
    def render_template(template, layout_name = nil, locals = {})
      layout_name = layout_name.call if layout_name.is_a? Proc
      layout = if layout_name.is_a? String then layout_name.split('/').last else '' end
      
      # ensure we aren't rendering e.g. text
      if template.respond_to?(:virtual_path) and @view.controller and @view.controller.respond_to?(:set_edifice_names)
        @view.controller.set_edifice_names(template.virtual_path.name, 
          template.virtual_path.prefix, layout)
      end
      
      super(template, layout_name, locals)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edifice-1.3.0 lib/edifice/renderer.rb
edifice-1.2.0 lib/edifice/renderer.rb