template_form 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da5ef52af3c84bb5b484452ecb693f4ce8ffe4c908f045c52ab9abede6030a7
4
- data.tar.gz: 425de0736d09aeca3f27d73b0970c8bce1036ff10fd9d7d0ad496159fae9d537
3
+ metadata.gz: 408026155358aa91f7c4751f36424be1364a7e21962c93501eaafad752e469ef
4
+ data.tar.gz: 8193bbf3b0241df0956e2b4957fea34e33aa6030e997f705ddf063b65caba4a7
5
5
  SHA512:
6
- metadata.gz: 710691873b95b172be68cda8357d68e6b1cf9d8ac733896fc18ca00485ca5687e46ed94ff0a73064f83d88dfa9045ed7fe7f0b6e9bf8909d2786a51173b5e009
7
- data.tar.gz: 29752a9dcd330f0c95a7e682cdfb6747094fe784335d89884c96fd66d0487339a436a69cd9e6c1cc74723652ff0d3efd07bb2b948a347c23bf3379694e59c4be
6
+ metadata.gz: 7e8e9c96f173d1ade04629e2f22457d2ea885c3a4262f8e2327b6ab13a172c992469f269922d907491fdd7668f93d43def8c1773a4ceb9cb293d57f922b7eaa4
7
+ data.tar.gz: ccf8c4be15bfa0d5e615a2ffa07125fcd58b55d9f2d0c71898d37d1678b2018dab187c48d014bcb1b6a2bbb647039c40a7a63b31a5c604f5feba8442399ed008
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Template Form makes defining the HTML your form inputs generate as simple as possible: you just write it out. Most other form builders, e.g. Simple Form, add a layer of indirection and make you use their own DSL.
4
4
 
5
- Templates are grouped so you can for example define both vertical and horizontal forms, or Bootstrap and Tailwind forms, in the same Rails app.
5
+ Templates are namespaced so you can define different HTML for different situations, e.g. stacked or horizontal, in the same Rails app.
6
6
 
7
- Right now Template Form includes templates for [Bulma](https://bulma.io/documentation/form/) but in time it will include templates for all the popular CSS frameworks.
7
+ Right now Template Form includes templates for [Bulma](https://bulma.io/documentation/form/) because those are defined by Bulma. For Tailwind, or Bootstrap, you define your inputs yourself.
8
8
 
9
9
  Template Form works with all template engines supported by [Tilt](https://github.com/rtomayko/tilt).
10
10
 
@@ -98,7 +98,7 @@ And then you will get this HTML instead:
98
98
 
99
99
  ### Defining your templates
100
100
 
101
- Your templates live at `/app/forms/<FORM TYPE>/` where `<FORM TYPE>` is a name that makes sense to you, and the value that you use with the `:form_type` option to `#template_form_with`.
101
+ Your templates live at `TemplateForm.template_path` which defaults to `/app/forms/<FORM TYPE>/` where `<FORM TYPE>` is a name that makes sense to you, and the value that you use with the `:form_type` option to `#template_form_with`.
102
102
 
103
103
  They should have these names:
104
104
 
@@ -92,7 +92,7 @@ module TemplateForm
92
92
  end
93
93
 
94
94
  def locations
95
- [ Pathname.new("#{Rails.root}/app/forms"),
95
+ [ TemplateForm.template_path,
96
96
  Pathname.new("#{__dir__}/templates") ]
97
97
  end
98
98
 
@@ -32,7 +32,7 @@ module TemplateForm
32
32
 
33
33
  options[:type] ||= 'password' if attribute_name.match(/password/)
34
34
 
35
- options.merge! view: @view
35
+ options.merge! view: @view if @view
36
36
 
37
37
  input_for(attribute_type).new(self, attribute_name, options).render
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module TemplateForm
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
data/lib/template_form.rb CHANGED
@@ -15,6 +15,14 @@ module TemplateForm
15
15
  @form_type = val
16
16
  end
17
17
 
18
+ def self.template_path
19
+ @template_path || Pathname.new("#{Rails.root}/app/forms")
20
+ end
21
+
22
+ def self.template_path=(val)
23
+ @template_path = Pathname.new(val)
24
+ end
25
+
18
26
  private
19
27
 
20
28
  def self.noop_field_error_proc
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.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-18 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack