Sha256: 446ce082ca2cdf83d4481e430ef7d7042f4965403399ee3e946f594b4d22f7eb
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
require 'ruhl' require 'ruhl/rails/ruhl_presenter' module Ruhl class Plugin < ActionView::TemplateHandler def initialize(action_view) @action_view = action_view end def render(template, options = {}) if layout = options[:layout] layout_template = @action_view.controller.send(:find_layout, layout, @action_view.controller.send(:default_template_format) ) else layout_template = @action_view.controller.active_layout end if layout_template options[:layout] = layout_template.filename options[:layout_source] = layout_template.source end 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 template = scope.view_paths.find_template(call_result) raise PartialNotFoundError.new(call_result) unless template render_nodes Nokogiri::HTML.fragment( template.source ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
ruhl-1.3.3 | lib/ruhl/rails.rb |
ruhl-1.3.2 | lib/ruhl/rails.rb |
ruhl-1.3.1 | lib/ruhl/rails.rb |
ruhl-1.3.0 | lib/ruhl/rails.rb |
ruhl-1.2.0 | lib/ruhl/rails.rb |
ruhl-1.1.1 | lib/ruhl/rails.rb |