Sha256: 554f2d8b59e6ad252a7f2f0d32246b346efc3b26d362b4e6f088fb6d953d39a7

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module AsyncPartial
  class Railtie < ::Rails::Railtie
    initializer 'async_partial' do
      ActiveSupport.on_load :action_view do
        ActionView::PartialRenderer.prepend AsyncPartial::Renderer
        ActionView::OutputBuffer.prepend AsyncPartial::ArrayBuffer
        ActionView::Base.prepend AsyncPartial::CaptureHelper

        begin
          require 'action_view/template/handlers/erb/erubi'
          require_relative 'handlers/erubi'

          ActionView::Template::Handlers::ERB.erb_implementation = ActionView::Template::Handlers::ERB::ThreadSafeErubi
        rescue LoadError
          begin
            require 'action_view/template/handlers/erb'
            require_relative 'handlers/erubis'

            ActionView::Template::Handlers::ERB.erb_implementation = ActionView::Template::Handlers::ERB::ThreadSafeErubis
          rescue LoadError
            raise 'No Erubi nor Erubis found.'
          end
        end

        if Gem.loaded_specs.detect {|g| g[0] == 'haml'}
          require 'haml/buffer'
          require_relative 'handlers/haml'
        end

        if Gem.loaded_specs.detect {|g| g[0] == 'slim'}
          require 'temple/generators/rails_output_buffer'
          require_relative 'handlers/slim'

          Temple::Templates::Rails(Slim::Engine, register_as: :slim, generator: Temple::Generators::ThreadedRailsOutputBuffer, disable_capture: true, streaming: true)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
async_partial-0.6.0 lib/async_partial/railtie.rb