File: bootstrap_form.rb

package info (click to toggle)
ruby-bootstrap-form 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 512 kB
  • sloc: ruby: 1,350; makefile: 4
file content (53 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# NOTE: The rich_text_area and rich_text_area_tag helpers are defined in a file
# with a different name and not in the usual autoload-reachable way.
# The following line is definitely need to make `bootstrap_form` work.
# rubocop:disable Lint/SuppressedException
begin
  require "#{Gem::Specification.find_by_name('actiontext').gem_dir}/app/helpers/action_text/tag_helper"
rescue Gem::MissingSpecError
end
# rubocop:enable Lint/SuppressedException

require "action_view"
require "action_pack"
require "bootstrap_form/action_view_extensions/form_helper"

module BootstrapForm
  extend ActiveSupport::Autoload

  eager_autoload do
    autoload :Configuration
    autoload :FormBuilder
    autoload :FormGroupBuilder
    autoload :FormGroup
    autoload :Components
    autoload :Inputs
    autoload :Helpers
  end

  class << self
    def eager_load!
      super
      BootstrapForm::Components.eager_load!
      BootstrapForm::Helpers.eager_load!
      BootstrapForm::Inputs.eager_load!
    end

    def config
      @config ||= BootstrapForm::Configuration.new
    end

    def configure
      yield config
    end
  end

  mattr_accessor :field_error_proc
  # rubocop:disable Style/ClassVars
  @@field_error_proc = proc do |html_tag, _instance_tag|
    html_tag
  end
  # rubocop:enable Style/ClassVars
end

require "bootstrap_form/engine" if defined?(Rails)