Sha256: b2d4601661bff840203722b622bdb697b68ab605bf9a3da34cf94c521e5a9f63

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 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

        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
        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.3.0 lib/async_partial/railtie.rb