template_form 0.4.6 → 0.4.7

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: a2dffdc1b897b10460d029723d7f286651388e59c7a637eded104e78898edbab
4
- data.tar.gz: bf8b340b369c8113fae4d5d6311a83383de8cb9bd832e10fbe41c2d7917cc960
3
+ metadata.gz: 9da5ef52af3c84bb5b484452ecb693f4ce8ffe4c908f045c52ab9abede6030a7
4
+ data.tar.gz: 425de0736d09aeca3f27d73b0970c8bce1036ff10fd9d7d0ad496159fae9d537
5
5
  SHA512:
6
- metadata.gz: 0ac600b29d24bb2d9bce1b63d7d1d75cd9b94b7c25c836ab3c23a734db71f2f22b361be6a49b7b16055585c7b3dc642e5f010d3846831ea0ed152cea5e26412f
7
- data.tar.gz: 1b2e8c6caf8c4fa2d897ae42941c6d4d6f234c9bee95422f307614dc69836146cb1f87a3e451321e033113bcce0e003f00b2b2acbf113c5eb85b0a3ecec47371
6
+ metadata.gz: 710691873b95b172be68cda8357d68e6b1cf9d8ac733896fc18ca00485ca5687e46ed94ff0a73064f83d88dfa9045ed7fe7f0b6e9bf8909d2786a51173b5e009
7
+ data.tar.gz: 29752a9dcd330f0c95a7e682cdfb6747094fe784335d89884c96fd66d0487339a436a69cd9e6c1cc74723652ff0d3efd07bb2b948a347c23bf3379694e59c4be
data/README.md CHANGED
@@ -111,6 +111,8 @@ They should have these names:
111
111
 
112
112
  Use whatever extension goes with your template engine.
113
113
 
114
+ You can have several variations of a template, for example a [text input with inline add-on](https://tailwindui.com/components/application-ui/forms/input-groups#component-3620fb44e0a49ebce229526254018508). First, write your template at `<BASE>_<VARIANT>.html.erb`; say, `text_input_inline_add_on.html.erb`. Then use a `with: <VARIANT>` option in your view, e.g. `<%= form.input :name, with: :inline_add_on %>`.
115
+
114
116
  Inside each template you can use the normal Rails form helpers. Here's the template for Bulma's [text input](https://github.com/airblade/template_form/blob/master/lib/template_form/templates/bulma/text_input.html.erb):
115
117
 
116
118
  ```erb
@@ -77,7 +77,10 @@ module TemplateForm
77
77
 
78
78
  # TemplateForm::TextInput -> text_input
79
79
  def template_name
80
- self.class.name.demodulize.underscore
80
+ @template_name ||= [
81
+ self.class.name.demodulize.underscore,
82
+ options.delete(:with)
83
+ ].compact.join('_')
81
84
  end
82
85
 
83
86
  def detect_template_path(name)
@@ -1,3 +1,3 @@
1
1
  module TemplateForm
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-16 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubygems_version: 3.2.33
140
+ rubygems_version: 3.4.10
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: A template-based form builder for Rails.