Sha256: 223a55aad2f47a08d524f947f1794f5fa8f72c5615f44ac7d0dd6a78ec75b47b

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require "slim-rails/version"
require "rails"
require "slim"
require "slim-rails/register_engine"

module Slim
  module Rails
    class Railtie < ::Rails::Railtie
      config.app_generators.template_engine :slim

      initializer "slim_rails.configure_template_digestor" do |app|
        Slim::Rails::RegisterEngine.register_engine(app, config)

        ActiveSupport.on_load(:action_view) do
          ActiveSupport.on_load(:after_initialize) do
            begin # rubocop:disable Style/RedundantBegin
              if defined?(CacheDigests::DependencyTracker)
                # 'cache_digests' gem being used (overrides Rails 4 implementation)
                CacheDigests::DependencyTracker.register_tracker :slim, CacheDigests::DependencyTracker::ERBTracker

                if ::Rails.env.development?
                  # recalculate cache digest keys for each request
                  CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new
                end
              elsif ::Rails.version.to_s >= "4.0"
                # will only apply if Rails 4, which includes 'action_view/dependency_tracker'
                require "action_view/dependency_tracker"
                ActionView::DependencyTracker.register_tracker :slim, ActionView::DependencyTracker::ERBTracker
              end
            rescue
              # likely this version of Rails doesn't support dependency tracking
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slim-rails-3.6.3 lib/slim-rails.rb
slim-rails-3.6.2 lib/slim-rails.rb
slim-rails-3.6.1 lib/slim-rails.rb
slim-rails-3.5.1 lib/slim-rails.rb