lifeform 0.2.0 → 0.3.0

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: c1a951565aa5729c703d08032dc10a135d57f39be110ea7a77f1daea226ea7b5
4
- data.tar.gz: b6411dc03979e7e69b30c51f99861565323ec39a7687148a3b4705a5ef4040f9
3
+ metadata.gz: 43833cf5f9112ae7e24d2f14e24f41629e7a728740ee768383c7072e9484eb69
4
+ data.tar.gz: db8424032dc11a96dc91ac8bb653e317bca8215de44c15664fed68c8b91f97de
5
5
  SHA512:
6
- metadata.gz: fb6e4f3177e0cc95c89ed7fe898ce977abbdfd755e53e6706edaf3c362508b56944f779f49bb0f82f4ce3f4f79817e4056352e15c2fbe7382defee52b2568037
7
- data.tar.gz: 2fd2aa7715782c21847cbaa5fac8ac6e692711a944ad6fe627c2df378380677d5ddd6b62429c7f073103a8750d5af7093ef2b6664b490f8f67d6594ecc1e82d6
6
+ metadata.gz: edd2ea3eabdad15d8dc27d2da4cf07b04bc0d00302761ecef5562a0dd999ffa5badf9f7c9eb53a322a309dee7d75cf1475aa952f1f1944cb5ff065517f0f0120
7
+ data.tar.gz: 33fb2e8b4276da626de9736cd568a6c34be23cade8eed0a0672cb1e909b5b911aca8136334d61e07d5b04937b450b7126066dfa1ebfb7c46d8af719d518147ec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifeform (0.2.0)
4
+ lifeform (0.3.0)
5
5
  activesupport (>= 6.0)
6
6
  papercraft (~> 0.24)
7
7
  zeitwerk (~> 2.5)
data/README.md CHANGED
@@ -51,6 +51,16 @@ Nested names based on models (aka `profile[name]`) and inferred action paths are
51
51
 
52
52
  Multiple component libraries and input types—and easy customizability via [Papercraft](https://github.com/digital-fabric/papercraft) templates—are a fundamental aspect of the architecture of Lifeform.
53
53
 
54
+ ### Automatic Field Rendering
55
+
56
+ For simple forms, you can avoid the need to render fields individually in your template. Given the form example above, you could write in your template:
57
+
58
+ ```erb
59
+ <%= render TestForm.new(url: "/path") %>
60
+ ```
61
+
62
+ And the fields defined in `TestForm` would render out automatically (since no block was provided to the `render` method).
63
+
54
64
  ## Development
55
65
 
56
66
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/lifeform/form.rb CHANGED
@@ -127,11 +127,15 @@ module Lifeform
127
127
  )
128
128
  end
129
129
 
130
- def render_in(view_context, &block) # rubocop:disable Metrics/AbcSize
130
+ def render_in(view_context, &block) # rubocop:disable Metrics
131
131
  form_tag = library::FORM_TAG
132
132
  parameters[:action] ||= url || (model ? view_context.send(self.class.const_get(:MODEL_PATH_HELPER), model) : nil)
133
133
 
134
- content = view_context.capture(self, &block)
134
+ content = if block
135
+ view_context.capture(self, &block)
136
+ else
137
+ self.class.fields.map { |k, _v| field(k).render_in(self) }.join
138
+ end
135
139
 
136
140
  return content unless emit_form_tag
137
141
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lifeform
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifeform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport