template_form 0.4.12 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5f2cf3168c27415bf3ac123a01a787df44d5619b2e4609ed1dceed3d93d1000
4
- data.tar.gz: 2114c0cdea916ce28cb317bcf81a48bec8829891fd6418ed60179fe5cc348c0a
3
+ metadata.gz: 6c834dd74c152f64f6433f9756b73f0ba4d21cc6690b65220356e0d5489b403c
4
+ data.tar.gz: e56aad9eb7633151f4e77624e60d231f4cc982f1670c6d3dfbf3b9d6900f57be
5
5
  SHA512:
6
- metadata.gz: d97036f8062989a917605297bc1f3227df8179c35d53aaa5548e401b27635fbc42ba57bc6c91fd58a8e8af63e2b54d9ba86f7258e3b464d5e5a6b551483d0157
7
- data.tar.gz: 9079c9237e978ea0013b0fe88f33a106c26564bad9993a517c68c3eb2fa29233ee3d2aaf3852f1a6f13a96bcffbbd3f02cb15f766df6bccf57559ca58cd17f4d
6
+ metadata.gz: 0da4c675cad3277a0ad7f0be48ea54ccad334c9674ea7b8c89b44b0285390fb104e07954ae55e8599f25c69b2c4d330c63de3290d61fa3e2478988f439316ede
7
+ data.tar.gz: ffb95977b0d992787746bf52e9a29d8f0ab51c2bb5f3c6233f50c606de08aff0b0d62a1d7aaab09ecb48722c11e14cd9477e7f43444d954ab10028f0d16a7f97
@@ -16,14 +16,11 @@ module TemplateForm
16
16
 
17
17
  attr_reader :form_type
18
18
 
19
- def initialize(*)
19
+ def initialize(...)
20
20
  super
21
- # Do not remove `:form_type` from `options`. It has to stay so
22
- # when `fields_for()` instantiates a new form builder for each
23
- # associated record, the second and subsequent ones have the
24
- # correct form type.
25
- @form_type = options[:form_type] || TemplateForm.form_type
26
- @view = options[:view]
21
+ parent_options = options[:parent_builder]&.options
22
+ @form_type = options[:form_type] || parent_options&.dig(:form_type) || TemplateForm.form_type
23
+ @view = options[:view] || parent_options&.dig(:view)
27
24
  end
28
25
 
29
26
  def input(attribute_name, options = {})
@@ -1,15 +1,12 @@
1
- <div class="field <%= html_options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", html_options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <%- label_options[:class] << ' label' %>
5
- <%- label_options[:class] << ' required' if html_options.delete(:required) %>
4
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => html_options.delete(:required)) %>
6
5
  <%= label attribute_name, label_text, label_options %>
7
6
  <% end %>
8
7
 
9
- <div class="control <%= html_options.delete(:control_class) %>">
10
- <%- html_options[:class] << ' select' %>
11
- <%- html_options[:class] << ' is-danger' if errors[attribute_name].present? %>
12
- <div class="<%= html_options[:class] %>">
8
+ <div class="<%= view.class_names("control", html_options.delete(:control_class)) %>">
9
+ <div class="<%= view.class_names(html_options[:class], "select", "is-danger" => errors[attribute_name].present?) %>">
13
10
  <%= collection_select(
14
11
  attribute_name,
15
12
  collection,
@@ -1,14 +1,12 @@
1
- <div class="field <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <%- label_options[:class] << ' label' %>
5
- <%- label_options[:class] << ' required' if options.delete(:required) %>
4
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
6
5
  <%= label attribute_name, label_text, label_options %>
7
6
  <% end %>
8
7
 
9
- <div class="control <%= options.delete(:control_class) %>">
10
- <%- options[:class] << ' input' %>
11
- <%- options[:class] << ' is-danger' if errors[attribute_name].present? %>
8
+ <div class="<%= view.class_names("control", options.delete(:control_class)) %>">
9
+ <%- options[:class] = view.class_names(options[:class], "input", "is-danger" => errors[attribute_name].present?) %>
12
10
  <%= text_field attribute_name, options %>
13
11
  </div>
14
12
 
@@ -1,14 +1,12 @@
1
- <div class="field <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <%- label_options[:class] << ' label' %>
5
- <%- label_options[:class] << ' required' if options.delete(:required) %>
4
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
6
5
  <%= label attribute_name, label_text, label_options %>
7
6
  <% end %>
8
7
 
9
8
  <div class="control">
10
- <%- options[:class] << ' textarea' %>
11
- <%- options[:class] << ' is-danger' if errors[attribute_name].present? %>
9
+ <%- options[:class] = view.class_names(options[:class], "textarea", "is-danger" => errors[attribute_name].present?) %>
12
10
  <%= text_area attribute_name, options %>
13
11
  </div>
14
12
 
@@ -1,16 +1,15 @@
1
- <div class="field is-horizontal <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
4
  <div class="field-label">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if options.delete(:required) %>
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
10
9
 
11
10
  <div class="field-body">
12
11
  <div class="field">
13
- <div class="control <%= options.delete(:control_class) %>">
12
+ <div class="<%= view.class_names("control", options.delete(:control_class)) %>">
14
13
  <label class="checkbox">
15
14
  <%= check_box attribute_name, options %>
16
15
  </label>
@@ -1,9 +1,8 @@
1
- <div class="field is-horizontal <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <div class="field-label <%= options.delete(:field_label_class) || 'is-normal' %>">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if options.delete(:required) %>
4
+ <div class="<%= view.class_names("field-label", options.delete(:field_label_class) { "is-normal" }) %>">
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
@@ -15,9 +14,8 @@
15
14
  https://github.com/jgthms/bulma/issues/640#issuecomment-415231212
16
15
  %>
17
16
  <div class="field">
18
- <div class="control <%= options.delete(:control_class) %>">
19
- <%- options[:class] << ' input' %>
20
- <%- options[:class] << ' is-danger' if errors[attribute_name].present? %>
17
+ <div class="<%= view.class_names("control", options.delete(:control_class)) %>">
18
+ <%- options[:class] = view.class_names(options[:class], "input", "is-danger" => errors[attribute_name].present?) %>
21
19
  <%= text_field attribute_name, options %>
22
20
  </div>
23
21
 
@@ -1,19 +1,16 @@
1
- <div class="field is-horizontal <%= html_options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", html_options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <div class="field-label <%= html_options.delete(:field_label_class) || 'is-normal' %>">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if html_options.delete(:required) %>
4
+ <div class="<%= view.class_names("field-label", html_options.delete(:field_label_class) { "is-normal" }) %>">
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => html_options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
10
9
 
11
10
  <div class="field-body">
12
- <div class="field <%= html_options.delete(:field_body_field_class) %>">
13
- <div class="control <%= html_options.delete(:control_class) %>">
14
- <%- html_options[:class] << ' select' %>
15
- <%- html_options[:class] << ' is-danger' if errors[attribute_name].present? %>
16
- <div class="<%= html_options[:class] %>">
11
+ <div class="<%= view.class_names("field", html_options.delete(:field_body_field_class)) %>">
12
+ <div class="<%= view.class_names("control", html_options.delete(:control_class)) %>">
13
+ <div class="<%= view.class_names(html_options[:class], "select", "is-danger" => errors[attribute_name].present?) %>">
17
14
  <%= grouped_collection_select(
18
15
  attribute_name,
19
16
  collection,
@@ -1,19 +1,16 @@
1
- <div class="field is-horizontal <%= html_options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", html_options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <div class="field-label <%= html_options.delete(:field_label_class) || 'is-normal' %>">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if html_options.delete(:required) %>
4
+ <div class="<%= view.class_names("field-label", html_options.delete(:field_label_class) { "is-normal" }) %>">
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => html_options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
10
9
 
11
10
  <div class="field-body">
12
- <div class="field <%= html_options.delete(:field_body_field_class) %>">
13
- <div class="control <%= html_options.delete(:control_class) %>">
14
- <%- html_options[:class] << ' select' %>
15
- <%- html_options[:class] << ' is-danger' if errors[attribute_name].present? %>
16
- <div class="<%= html_options[:class] %>">
11
+ <div class="<%= view.class_names("field", html_options.delete(:field_body_field_class)) %>">
12
+ <div class="<%= view.class_names("control", html_options.delete(:control_class)) %>">
13
+ <div class="<%= view.class_names(html_options[:class], "select", "is-danger" => errors[attribute_name].present?) %>">
17
14
  <%= collection_select(
18
15
  attribute_name,
19
16
  collection,
@@ -1,18 +1,16 @@
1
- <div class="field is-horizontal <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <div class="field-label <%= options.delete(:field_label_class) || 'is-normal' %>">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if options.delete(:required) %>
4
+ <div class="<%= view.class_names("field-label", options.delete(:field_label_class) { "is-normal" }) %>">
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
10
9
 
11
10
  <div class="field-body">
12
11
  <div class="field">
13
- <div class="control <%= options.delete(:control_class) %>">
14
- <%- options[:class] << ' input' %>
15
- <%- options[:class] << ' is-danger' if errors[attribute_name].present? %>
12
+ <div class="<%= view.class_names("control", options.delete(:control_class)) %>">
13
+ <%- options[:class] = view.class_names(options[:class], "input", "is-danger" => errors[attribute_name].present?) %>
16
14
  <%= text_field attribute_name, options %>
17
15
  </div>
18
16
 
@@ -1,18 +1,16 @@
1
- <div class="field is-horizontal <%= options.delete(:field_class) %>">
1
+ <div class="<%= view.class_names("field", "is-horizontal", options.delete(:field_class)) %>">
2
2
 
3
3
  <% if has_label %>
4
- <div class="field-label <%= options.delete(:field_label_class) || 'is-normal' %>">
5
- <%- label_options[:class] << ' label' %>
6
- <%- label_options[:class] << ' required' if options.delete(:required) %>
4
+ <div class="<%= view.class_names("field-label", options.delete(:field_label_class) { "is-normal" }) %>">
5
+ <%- label_options[:class] = view.class_names(label_options[:class], "label", "required" => options.delete(:required)) %>
7
6
  <%= label attribute_name, label_text, label_options %>
8
7
  </div>
9
8
  <% end %>
10
9
 
11
10
  <div class="field-body">
12
11
  <div class="field">
13
- <div class="control <%= options.delete(:control_class) %>">
14
- <%- options[:class] << ' textarea' %>
15
- <%- options[:class] << ' is-danger' if errors[attribute_name].present? %>
12
+ <div class="<%= view.class_names("control", options.delete(:control_class)) %>">
13
+ <%- options[:class] = view.class_names(options[:class], "textarea", "is-danger" => errors[attribute_name].present?) %>
16
14
  <%= text_area attribute_name, options %>
17
15
  </div>
18
16
 
@@ -1,3 +1,3 @@
1
1
  module TemplateForm
2
- VERSION = "0.4.12"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency 'actionpack', '> 5.0'
24
+ spec.add_dependency 'actionpack', '>= 6.1.0'
25
25
  spec.add_dependency 'tilt', '~> 2.0'
26
26
 
27
27
  spec.add_development_dependency "bundler"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-07 00:00:00.000000000 Z
11
+ date: 2026-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: 6.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: 6.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement