Sha256: 21eefe7208343c8892cd1d2c89c8f9c9e8764ec966df267bf2233f1c19145ef5

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module HotwireCombobox
  class Engine < ::Rails::Engine
    isolate_namespace HotwireCombobox

    initializer "hotwire_combobox.view_helpers" do
      ActiveSupport.on_load :action_view do
        include HotwireCombobox::Helper

        unless HotwireCombobox.bypass_convenience_methods?
          module FormBuilderExtensions
            def combobox(*args, **kwargs)
              @template.hw_combobox_tag *args, **kwargs.merge(form: self)
            end
          end

          ActionView::Helpers::FormBuilder.include FormBuilderExtensions
        end
      end
    end

    initializer "hotwire_combobox.importmap", before: "importmap" do |app|
      if Rails.application.respond_to?(:importmap)
        app.config.importmap.paths << Engine.root.join("config/importmap.rb")
      end
    end

    initializer "hotwire_combobox.assets.precompile" do |app|
      if Rails.application.config.respond_to?(:assets)
        Dir.glob(Engine.root.join("app/assets/**/*.{js,css}")).each do |path|
          logical_path = Pathname.new(path).relative_path_from(Pathname.new(Engine.root.join("app/assets"))).to_s
          app.config.assets.precompile << logical_path
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hotwire_combobox-0.1.19 lib/hotwire_combobox/engine.rb