Sha256: ef42a3cd3a5f611ab792e5582c8f8dcb1f628014e2d5a590f39df6686b028eef

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

require 'ruhl'

module Ruhl
  class Plugin < ActionView::TemplateHandler

    def initialize(action_view)
      @action_view = action_view
    end
    
    def render(template, options = {})
      layout = @action_view.controller.send(:active_layout)

      options[:layout]        = layout.filename
      options[:layout_source] = layout.source

      Ruhl::Engine.new(template.source, options).render(@action_view)
    end
  end
end

ActionView::Template.register_template_handler(:ruhl, Ruhl::Plugin)

ActionView::Template.exempt_from_layout(:ruhl)


module Ruhl
  class Engine
    private

    def render_partial(tag, code)
      file = execute_ruby(tag, code)

      template = scope.view_paths.find_template(file)

      raise PartialNotFoundError.new(file) unless template

      render_file( template.source )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruhl-0.9.5 lib/ruhl/rails.rb