Sha256: 91a53b0d64d5ab9636bdc44e0ebd010bf93b1dba9fa41ac56fccad03c9b60267

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

require "sprockets/railtie"

module Trestle
  class Engine < ::Rails::Engine
    isolate_namespace Trestle
    self.routes.default_scope = {}

    # Application assets
    config.assets.precompile << "trestle/admin.css" << "trestle/admin.js" << "trestle/custom.css"

    # Vendor assets
    %w(eot svg ttf woff woff2).each do |ext|
      config.assets.precompile << "trestle/fa-*.#{ext}"
    end

    initializer "trestle.automount" do |app|
      if Trestle.config.automount
        app.routes.prepend do
          mount Trestle::Engine => Trestle.config.path
        end
      end
    end

    initializer "trestle.draper" do |app|
      if defined?(Draper)
        Draper::CollectionDecorator.delegate :current_page, :total_pages, :limit_value, :entry_name, :total_count, :offset_value, :last_page?
      end
    end

    initializer "trestle.theme" do |app|
      # Enable theme compilation
      if Trestle.config.theme
        app.config.assets.paths << root.join("frontend/theme").to_s
        app.config.assets.precompile << "trestle/theme.css"
      end
    end

    initializer "trestle.turbolinks" do |app|
      # Optional turbolinks
      app.config.assets.precompile << "turbolinks.js" if Trestle.config.turbolinks
    end

    config.to_prepare do
      Engine.reset_helpers!
    end

    config.after_initialize do |app|
      reloader = Trestle::Reloader.new(*app.watchable_args)
      reloader.install(app) unless app.config.eager_load
    end

    def reset_helpers!
      @helpers = nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trestle-0.9.8 lib/trestle/engine.rb
trestle-0.9.7 lib/trestle/engine.rb
trestle-0.9.6 lib/trestle/engine.rb
trestle-0.9.5 lib/trestle/engine.rb
trestle-0.9.4 lib/trestle/engine.rb