lifeform 0.2.0 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -0
- data/lib/lifeform/form.rb +6 -2
- data/lib/lifeform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43833cf5f9112ae7e24d2f14e24f41629e7a728740ee768383c7072e9484eb69
|
4
|
+
data.tar.gz: db8424032dc11a96dc91ac8bb653e317bca8215de44c15664fed68c8b91f97de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd2ea3eabdad15d8dc27d2da4cf07b04bc0d00302761ecef5562a0dd999ffa5badf9f7c9eb53a322a309dee7d75cf1475aa952f1f1944cb5ff065517f0f0120
|
7
|
+
data.tar.gz: 33fb2e8b4276da626de9736cd568a6c34be23cade8eed0a0672cb1e909b5b911aca8136334d61e07d5b04937b450b7126066dfa1ebfb7c46d8af719d518147ec
|
data/Gemfile.lock
CHANGED
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
|
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 =
|
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
|
|
data/lib/lifeform/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|