lifeform 0.15.0 → 0.17.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/.rubocop.yml +15 -1
- data/.ruby-version +1 -1
- data/.solargraph.yml +13 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +6 -6
- data/Gemfile.lock +86 -83
- data/README.md +2 -6
- data/Rakefile +1 -1
- data/lib/lifeform/form.rb +44 -6
- data/lib/lifeform/libraries/default/html.rb +26 -0
- data/lib/lifeform/version.rb +1 -1
- data/lib/lifeform.rb +1 -1
- data/lifeform.gemspec +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 283c7f42b6108a032fe1ba52472eeaedac36cc0b07e70eb061f23b931724b729
|
|
4
|
+
data.tar.gz: 8640ba714e28cf0a0eb0a5dd7c7f48aaac37e75d2b0c6170a135983570abb4ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05eb1d7fbc094ae6e3450906da2671e4f4604f7f0fd8da0acdf734a9e445d129c7796c1cb8cb0a703787cbd4d7f43589dbdf56c0af7f4f4ce73076d561eaeb27
|
|
7
|
+
data.tar.gz: f6a208d9430d77c6bb8087f7331b197fc76bdb0d7f88d3ef72f9406d8e00823a7bb36c49838c682961aee50934e40b795389086655221fba2bb70b870a0941d8
|
data/.rubocop.yml
CHANGED
|
@@ -7,7 +7,7 @@ inherit_gem:
|
|
|
7
7
|
rubocop-bridgetown: .rubocop.yml
|
|
8
8
|
|
|
9
9
|
AllCops:
|
|
10
|
-
TargetRubyVersion: 3.
|
|
10
|
+
TargetRubyVersion: 3.2
|
|
11
11
|
NewCops: enable
|
|
12
12
|
|
|
13
13
|
Exclude:
|
|
@@ -28,10 +28,20 @@ AllCops:
|
|
|
28
28
|
Layout/MultilineBlockLayout:
|
|
29
29
|
Enabled: false
|
|
30
30
|
|
|
31
|
+
Layout/SpaceBeforeFirstArg:
|
|
32
|
+
Enabled: false
|
|
33
|
+
|
|
34
|
+
Layout/SpaceBeforeBlockBraces:
|
|
35
|
+
Enabled: false
|
|
36
|
+
|
|
31
37
|
Metrics/AbcSize:
|
|
32
38
|
Exclude:
|
|
33
39
|
- test/**/*.rb
|
|
34
40
|
|
|
41
|
+
Metrics/BlockLength:
|
|
42
|
+
Exclude:
|
|
43
|
+
- test/**/*.rb
|
|
44
|
+
|
|
35
45
|
Metrics/ClassLength:
|
|
36
46
|
Exclude:
|
|
37
47
|
- test/**/*.rb
|
|
@@ -42,3 +52,7 @@ Metrics/MethodLength:
|
|
|
42
52
|
|
|
43
53
|
Layout/LineLength:
|
|
44
54
|
Max: 120
|
|
55
|
+
|
|
56
|
+
Lint/Void:
|
|
57
|
+
Exclude:
|
|
58
|
+
- test/**/*.rb
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
ruby-3.2.6
|
data/.solargraph.yml
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
.
|
|
11
|
+
|
|
12
|
+
## [0.17.0] - 2025-12-16
|
|
13
|
+
|
|
14
|
+
- Add `fragment` "field" type for adding arbitrary HTML sections to forms
|
|
15
|
+
- Allow disabling csrf protection
|
|
16
|
+
- Convert tests to spec style and add "Intuitive Expectations"
|
|
17
|
+
- remove rails-dom-testing
|
|
18
|
+
- bump minimum Ruby to 3.2
|
|
19
|
+
|
|
20
|
+
## [0.16.0] - 2025-09-11
|
|
21
|
+
|
|
22
|
+
- Migrate repo to Codeberg
|
|
23
|
+
- Minimum supported Ruby version is 3.1
|
|
24
|
+
|
|
10
25
|
## [0.15.0] - 2024-04-17
|
|
11
26
|
|
|
12
27
|
- Add compatibility fixes re: Streamlined
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
source "https://
|
|
3
|
+
source "https://gem.coop"
|
|
4
4
|
|
|
5
5
|
# Specify your gem's dependencies in lifeform.gemspec
|
|
6
6
|
gemspec
|
|
@@ -12,10 +12,10 @@ gem "minitest-reporters", "~> 1.5"
|
|
|
12
12
|
|
|
13
13
|
gem "rubocop", "~> 1.21"
|
|
14
14
|
gem "rubocop-bridgetown", "~> 0.4"
|
|
15
|
-
|
|
16
|
-
gem "solargraph", "~> 0.45.0"
|
|
17
|
-
|
|
18
|
-
gem "rails-dom-testing", "~> 2.0"
|
|
19
|
-
|
|
20
15
|
gem "rubocop-minitest", "~> 0.20.0"
|
|
21
16
|
gem "rubocop-rake", "~> 0.6.0"
|
|
17
|
+
|
|
18
|
+
gem "solargraph", "~> 0.50"
|
|
19
|
+
|
|
20
|
+
gem "bridgetown-foundation", "~> 2.0.4"
|
|
21
|
+
gem "nokolexbor", "~> 0.6.2"
|
data/Gemfile.lock
CHANGED
|
@@ -1,145 +1,148 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
lifeform (0.
|
|
4
|
+
lifeform (0.17.0)
|
|
5
5
|
hash_with_dot_access (>= 1.2)
|
|
6
6
|
sequel (>= 5.72)
|
|
7
7
|
streamlined (>= 0.2.0)
|
|
8
8
|
zeitwerk (~> 2.5)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
|
-
remote: https://
|
|
11
|
+
remote: https://gem.coop/
|
|
12
12
|
specs:
|
|
13
|
-
activesupport (7.1.3.2)
|
|
14
|
-
base64
|
|
15
|
-
bigdecimal
|
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
|
-
connection_pool (>= 2.2.5)
|
|
18
|
-
drb
|
|
19
|
-
i18n (>= 1.6, < 2)
|
|
20
|
-
minitest (>= 5.1)
|
|
21
|
-
mutex_m
|
|
22
|
-
tzinfo (~> 2.0)
|
|
23
13
|
ansi (1.5.0)
|
|
24
|
-
ast (2.4.
|
|
14
|
+
ast (2.4.3)
|
|
25
15
|
backport (1.2.0)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
json (2.7.2)
|
|
42
|
-
kramdown (2.4.0)
|
|
43
|
-
rexml
|
|
16
|
+
benchmark (0.5.0)
|
|
17
|
+
bigdecimal (3.3.1)
|
|
18
|
+
bridgetown-foundation (2.0.4)
|
|
19
|
+
hash_with_dot_access (~> 2.0)
|
|
20
|
+
inclusive (~> 1.0)
|
|
21
|
+
zeitwerk (~> 2.5)
|
|
22
|
+
builder (3.3.0)
|
|
23
|
+
diff-lcs (1.6.2)
|
|
24
|
+
erubi (1.13.1)
|
|
25
|
+
hash_with_dot_access (2.2.0)
|
|
26
|
+
inclusive (1.1.0)
|
|
27
|
+
jaro_winkler (1.6.1)
|
|
28
|
+
json (2.16.0)
|
|
29
|
+
kramdown (2.5.1)
|
|
30
|
+
rexml (>= 3.3.9)
|
|
44
31
|
kramdown-parser-gfm (1.1.0)
|
|
45
32
|
kramdown (~> 2.0)
|
|
46
|
-
language_server-protocol (3.17.0.
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
language_server-protocol (3.17.0.5)
|
|
34
|
+
lint_roller (1.1.0)
|
|
35
|
+
logger (1.7.0)
|
|
36
|
+
minitest (5.26.0)
|
|
37
|
+
minitest-reporters (1.7.1)
|
|
49
38
|
ansi
|
|
50
39
|
builder
|
|
51
40
|
minitest (>= 5.0)
|
|
52
41
|
ruby-progressbar
|
|
53
|
-
|
|
54
|
-
nokogiri (1.16.4-arm64-darwin)
|
|
42
|
+
nokogiri (1.18.10-arm64-darwin)
|
|
55
43
|
racc (~> 1.4)
|
|
56
|
-
nokogiri (1.
|
|
44
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
|
57
45
|
racc (~> 1.4)
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
nokolexbor (0.6.2-x86_64-linux)
|
|
47
|
+
observer (0.1.2)
|
|
48
|
+
ostruct (0.6.3)
|
|
49
|
+
parallel (1.27.0)
|
|
50
|
+
parser (3.3.10.0)
|
|
60
51
|
ast (~> 2.4.1)
|
|
61
52
|
racc
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
activesupport (>= 5.0.0)
|
|
65
|
-
minitest
|
|
66
|
-
nokogiri (>= 1.6)
|
|
53
|
+
prism (1.6.0)
|
|
54
|
+
racc (1.8.1)
|
|
67
55
|
rainbow (3.1.1)
|
|
68
|
-
rake (13.
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
rake (13.3.1)
|
|
57
|
+
rbs (3.9.5)
|
|
58
|
+
logger
|
|
59
|
+
regexp_parser (2.11.3)
|
|
60
|
+
reverse_markdown (3.0.0)
|
|
71
61
|
nokogiri
|
|
72
|
-
rexml (3.
|
|
73
|
-
rubocop (1.
|
|
62
|
+
rexml (3.4.4)
|
|
63
|
+
rubocop (1.81.7)
|
|
74
64
|
json (~> 2.3)
|
|
75
|
-
language_server-protocol (
|
|
65
|
+
language_server-protocol (~> 3.17.0.2)
|
|
66
|
+
lint_roller (~> 1.1.0)
|
|
76
67
|
parallel (~> 1.10)
|
|
77
68
|
parser (>= 3.3.0.2)
|
|
78
69
|
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
-
regexp_parser (>=
|
|
80
|
-
|
|
81
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
70
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
71
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
82
72
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>= 2.4.0, <
|
|
84
|
-
rubocop-ast (1.
|
|
85
|
-
parser (>= 3.3.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
rubocop
|
|
73
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
74
|
+
rubocop-ast (1.47.1)
|
|
75
|
+
parser (>= 3.3.7.2)
|
|
76
|
+
prism (~> 1.4)
|
|
77
|
+
rubocop-bridgetown (0.7.0)
|
|
78
|
+
rubocop (~> 1.72)
|
|
79
|
+
rubocop-performance (~> 1.24)
|
|
89
80
|
rubocop-minitest (0.20.1)
|
|
90
81
|
rubocop (>= 0.90, < 2.0)
|
|
91
|
-
rubocop-performance (1.
|
|
92
|
-
|
|
93
|
-
rubocop
|
|
82
|
+
rubocop-performance (1.26.1)
|
|
83
|
+
lint_roller (~> 1.1)
|
|
84
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
85
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
94
86
|
rubocop-rake (0.6.0)
|
|
95
87
|
rubocop (~> 1.0)
|
|
96
88
|
ruby-progressbar (1.13.0)
|
|
97
|
-
sequel (5.
|
|
89
|
+
sequel (5.98.0)
|
|
98
90
|
bigdecimal
|
|
99
|
-
serbea (2.
|
|
100
|
-
erubi (>= 1.
|
|
101
|
-
tilt (
|
|
102
|
-
solargraph (0.
|
|
91
|
+
serbea (2.4.0)
|
|
92
|
+
erubi (>= 1.13)
|
|
93
|
+
tilt (>= 2.6)
|
|
94
|
+
solargraph (0.57.0)
|
|
103
95
|
backport (~> 1.2)
|
|
104
|
-
benchmark
|
|
105
|
-
bundler (
|
|
96
|
+
benchmark (~> 0.4)
|
|
97
|
+
bundler (~> 2.0)
|
|
106
98
|
diff-lcs (~> 1.4)
|
|
107
|
-
|
|
108
|
-
jaro_winkler (~> 1.5)
|
|
99
|
+
jaro_winkler (~> 1.6, >= 1.6.1)
|
|
109
100
|
kramdown (~> 2.3)
|
|
110
101
|
kramdown-parser-gfm (~> 1.1)
|
|
102
|
+
logger (~> 1.6)
|
|
103
|
+
observer (~> 0.1)
|
|
104
|
+
ostruct (~> 0.6)
|
|
111
105
|
parser (~> 3.0)
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
prism (~> 1.4)
|
|
107
|
+
rbs (>= 3.6.1, <= 4.0.0.dev.4)
|
|
108
|
+
reverse_markdown (~> 3.0)
|
|
109
|
+
rubocop (~> 1.76)
|
|
114
110
|
thor (~> 1.0)
|
|
115
111
|
tilt (~> 2.0)
|
|
116
112
|
yard (~> 0.9, >= 0.9.24)
|
|
117
|
-
|
|
113
|
+
yard-activesupport-concern (~> 0.0)
|
|
114
|
+
yard-solargraph (~> 0.1)
|
|
115
|
+
streamlined (0.6.2)
|
|
118
116
|
serbea (>= 2.1)
|
|
119
117
|
zeitwerk (~> 2.5)
|
|
120
|
-
thor (1.
|
|
121
|
-
tilt (2.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
unicode-
|
|
125
|
-
yard (0.9.
|
|
126
|
-
|
|
118
|
+
thor (1.4.0)
|
|
119
|
+
tilt (2.6.1)
|
|
120
|
+
unicode-display_width (3.2.0)
|
|
121
|
+
unicode-emoji (~> 4.1)
|
|
122
|
+
unicode-emoji (4.1.0)
|
|
123
|
+
yard (0.9.37)
|
|
124
|
+
yard-activesupport-concern (0.0.1)
|
|
125
|
+
yard (>= 0.8)
|
|
126
|
+
yard-solargraph (0.1.0)
|
|
127
|
+
yard (~> 0.9)
|
|
128
|
+
zeitwerk (2.7.3)
|
|
127
129
|
|
|
128
130
|
PLATFORMS
|
|
129
131
|
arm64-darwin-21
|
|
130
132
|
x86_64-linux
|
|
131
133
|
|
|
132
134
|
DEPENDENCIES
|
|
135
|
+
bridgetown-foundation (~> 2.0.4)
|
|
133
136
|
lifeform!
|
|
134
137
|
minitest (~> 5.0)
|
|
135
138
|
minitest-reporters (~> 1.5)
|
|
136
|
-
|
|
139
|
+
nokolexbor (~> 0.6.2)
|
|
137
140
|
rake (~> 13.0)
|
|
138
141
|
rubocop (~> 1.21)
|
|
139
142
|
rubocop-bridgetown (~> 0.4)
|
|
140
143
|
rubocop-minitest (~> 0.20.0)
|
|
141
144
|
rubocop-rake (~> 0.6.0)
|
|
142
|
-
solargraph (~> 0.
|
|
145
|
+
solargraph (~> 0.50)
|
|
143
146
|
|
|
144
147
|
BUNDLED WITH
|
|
145
148
|
2.3.3
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lifeform
|
|
2
2
|
|
|
3
|
-
Component-centric form object rendering for Ruby
|
|
3
|
+
Component-centric form object rendering for Ruby focused on the [Bridgetown](https://www.bridgetownrb.com) (and Roda) framework.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -76,12 +76,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
76
76
|
|
|
77
77
|
## Contributing
|
|
78
78
|
|
|
79
|
-
Bug reports and pull requests are welcome on GitHub at https://
|
|
79
|
+
Bug reports and pull requests are welcome on GitHub at https://codeberg.org/jaredwhite/lifeform. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://codeberg.org/jaredwhite/lifeform/src/main/CODE_OF_CONDUCT.md).
|
|
80
80
|
|
|
81
81
|
## License
|
|
82
82
|
|
|
83
83
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
84
|
-
|
|
85
|
-
## Code of Conduct
|
|
86
|
-
|
|
87
|
-
Everyone interacting in the Lifeform project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bridgetownrb/lifeform/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/lib/lifeform/form.rb
CHANGED
|
@@ -9,8 +9,9 @@ module Lifeform
|
|
|
9
9
|
|
|
10
10
|
# A form object which stores field definitions and can be rendered as a component
|
|
11
11
|
class Form
|
|
12
|
-
|
|
12
|
+
extend Streamlined::Helpers
|
|
13
13
|
extend Sequel::Inflections
|
|
14
|
+
include Streamlined::Renderable
|
|
14
15
|
|
|
15
16
|
MODEL_PATH_HELPER = :polymorphic_path
|
|
16
17
|
|
|
@@ -30,6 +31,8 @@ module Lifeform
|
|
|
30
31
|
|
|
31
32
|
def configuration = @configuration ||= HashWithDotAccess::Hash.new
|
|
32
33
|
|
|
34
|
+
def disable_csrf_protection! = configuration.disable_csrf_protection = true
|
|
35
|
+
|
|
33
36
|
# @param block [Proc, nil]
|
|
34
37
|
# @return [Hash<Symbol, FieldDefinition>]
|
|
35
38
|
def fields(&block)
|
|
@@ -52,6 +55,26 @@ module Lifeform
|
|
|
52
55
|
fields[name] = FieldDefinition.new(type, Libraries.const_get(camelize(library)), parameters)
|
|
53
56
|
end
|
|
54
57
|
|
|
58
|
+
# Add an HTML fragment which will be auto-rendered or manually rendered like any field.
|
|
59
|
+
# Use Streamlined helpers inside a squiggly heredoc passed via the block which will be
|
|
60
|
+
# executed within the view context (requires it have `include Streamlined::Helpers`)
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# fragment :footer do |form| <<~HTML
|
|
64
|
+
# <form-footer>
|
|
65
|
+
# <p>
|
|
66
|
+
# <img src="#{text->{ asset_path("thanks.png") }} />
|
|
67
|
+
# Thanks for filling out our form!
|
|
68
|
+
# </p>
|
|
69
|
+
# #{render form.field(:submit, label: t("users.sign_up"))}
|
|
70
|
+
# </form-footer>
|
|
71
|
+
# HTML
|
|
72
|
+
# end
|
|
73
|
+
#
|
|
74
|
+
# @param name [Symbol]
|
|
75
|
+
# @yieldparam form [Lifeform::Form] - instance of the form being rendered
|
|
76
|
+
def fragment(name, &block) = field(:"__#{name}", library: :default, type: :html, body: block)
|
|
77
|
+
|
|
55
78
|
def subform(name, klass, parent_name: nil)
|
|
56
79
|
subforms[name.to_sym] = { class: klass, parent_name: parent_name }
|
|
57
80
|
end
|
|
@@ -130,12 +153,19 @@ module Lifeform
|
|
|
130
153
|
attr_reader :parent_name
|
|
131
154
|
|
|
132
155
|
def initialize( # rubocop:disable Metrics/ParameterLists
|
|
133
|
-
model = nil,
|
|
156
|
+
model = nil,
|
|
157
|
+
url: nil,
|
|
158
|
+
library: self.class.library,
|
|
159
|
+
emit_form_tag: true,
|
|
160
|
+
parent_name: nil,
|
|
161
|
+
view_context: nil,
|
|
162
|
+
**parameters
|
|
134
163
|
)
|
|
135
164
|
@model, @url, @library_name, @parameters, @emit_form_tag, @parent_name =
|
|
136
165
|
model, url, library, parameters, emit_form_tag, parent_name
|
|
137
166
|
@library = Libraries.const_get(self.class.send(:camelize, @library_name))
|
|
138
167
|
@subform_instances = {}
|
|
168
|
+
@_view_context = view_context
|
|
139
169
|
|
|
140
170
|
self.class.initialize_field_definitions!
|
|
141
171
|
|
|
@@ -144,6 +174,8 @@ module Lifeform
|
|
|
144
174
|
verify_method
|
|
145
175
|
end
|
|
146
176
|
|
|
177
|
+
def configuration = self.class.configuration
|
|
178
|
+
|
|
147
179
|
def verify_method
|
|
148
180
|
return if %w[get post].include?(parameters[:method].to_s.downcase)
|
|
149
181
|
|
|
@@ -171,6 +203,8 @@ module Lifeform
|
|
|
171
203
|
end
|
|
172
204
|
end
|
|
173
205
|
|
|
206
|
+
def include_authenticity_token? = !configuration.disable_csrf_protection
|
|
207
|
+
|
|
174
208
|
def attributes
|
|
175
209
|
@attributes ||= self.class.parameters_to_attributes(parameters)
|
|
176
210
|
end
|
|
@@ -185,21 +219,25 @@ module Lifeform
|
|
|
185
219
|
)
|
|
186
220
|
end
|
|
187
221
|
|
|
222
|
+
def fragment(name, **) = field(:"__#{name}", **)
|
|
223
|
+
|
|
188
224
|
def subform(name, model = nil)
|
|
189
225
|
@subform_instances[name.to_sym] ||= self.class.subforms[name.to_sym][:class].new(
|
|
190
226
|
model,
|
|
191
227
|
emit_form_tag: false,
|
|
192
|
-
parent_name: self.class.subforms[name.to_sym][:parent_name] || self.class.name_of_model(self.model)
|
|
228
|
+
parent_name: self.class.subforms[name.to_sym][:parent_name] || self.class.name_of_model(self.model),
|
|
229
|
+
view_context: helpers
|
|
193
230
|
)
|
|
194
231
|
end
|
|
195
232
|
|
|
196
|
-
def template(&block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
233
|
+
def template(&block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
197
234
|
form_tag = library::FORM_TAG
|
|
198
235
|
parameters[:action] ||= url || (model ? helpers.send(self.class.const_get(:MODEL_PATH_HELPER), model) : nil)
|
|
236
|
+
output_token = include_authenticity_token? && parameters[:method].to_s.casecmp("get").zero?.!
|
|
199
237
|
|
|
200
238
|
html -> { <<~HTML # rubocop:disable Bridgetown/InsecureHeredoc
|
|
201
239
|
<#{form_tag} #{html_attributes attributes}>
|
|
202
|
-
#{add_authenticity_token
|
|
240
|
+
#{add_authenticity_token if output_token}
|
|
203
241
|
#{@method_tag&.() || ""}
|
|
204
242
|
#{block ? capture(self, &block) : auto_render_fields}
|
|
205
243
|
</#{form_tag}>
|
|
@@ -210,7 +248,7 @@ module Lifeform
|
|
|
210
248
|
def auto_render_fields = html_map(self.class.fields) { |k, _v| render(field(k)) }
|
|
211
249
|
|
|
212
250
|
def render(field_object)
|
|
213
|
-
field_object.render_in(helpers
|
|
251
|
+
field_object.render_in(helpers)
|
|
214
252
|
end
|
|
215
253
|
end
|
|
216
254
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lifeform
|
|
4
|
+
module Libraries
|
|
5
|
+
class Default
|
|
6
|
+
class Html
|
|
7
|
+
include Streamlined::Renderable
|
|
8
|
+
|
|
9
|
+
attr_reader :form, :field_definition, :body
|
|
10
|
+
|
|
11
|
+
def initialize(form, field_definition, **attributes)
|
|
12
|
+
@form = form
|
|
13
|
+
@field_definition = field_definition
|
|
14
|
+
|
|
15
|
+
@attributes =
|
|
16
|
+
Lifeform::Form.parameters_to_attributes(field_definition.parameters).merge(attributes)
|
|
17
|
+
@body = @attributes[:body]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def template
|
|
21
|
+
html->{ helpers.instance_exec(form, &body) }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/lifeform/version.rb
CHANGED
data/lib/lifeform.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Lifeform
|
|
|
9
9
|
class Error < StandardError; end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
if defined?(Bridgetown)
|
|
12
|
+
if defined?(Bridgetown) && Bridgetown.respond_to?(:initializer)
|
|
13
13
|
Bridgetown.initializer :lifeform do |config|
|
|
14
14
|
config.hook :authtown, :initialized do |rodauth|
|
|
15
15
|
Lifeform::Form.rodauth = rodauth
|
data/lifeform.gemspec
CHANGED
|
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = "maintainers@bridgetownrb.com"
|
|
10
10
|
|
|
11
11
|
spec.summary = "Component-centric form object rendering for Ruby"
|
|
12
|
-
spec.homepage = "https://
|
|
12
|
+
spec.homepage = "https://codeberg.org/jaredwhite/lifeform"
|
|
13
13
|
spec.license = "MIT"
|
|
14
|
-
spec.required_ruby_version = ">= 3.
|
|
14
|
+
spec.required_ruby_version = ">= 3.1"
|
|
15
15
|
spec.metadata["rubygems_mfa_required"] = "true"
|
|
16
16
|
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
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.17.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:
|
|
11
|
+
date: 2025-12-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hash_with_dot_access
|
|
@@ -74,6 +74,7 @@ extra_rdoc_files: []
|
|
|
74
74
|
files:
|
|
75
75
|
- ".rubocop.yml"
|
|
76
76
|
- ".ruby-version"
|
|
77
|
+
- ".solargraph.yml"
|
|
77
78
|
- CHANGELOG.md
|
|
78
79
|
- CODE_OF_CONDUCT.md
|
|
79
80
|
- Gemfile
|
|
@@ -89,6 +90,7 @@ files:
|
|
|
89
90
|
- lib/lifeform/form.rb
|
|
90
91
|
- lib/lifeform/libraries/default.rb
|
|
91
92
|
- lib/lifeform/libraries/default/button.rb
|
|
93
|
+
- lib/lifeform/libraries/default/html.rb
|
|
92
94
|
- lib/lifeform/libraries/default/input.rb
|
|
93
95
|
- lib/lifeform/libraries/default/submit_button.rb
|
|
94
96
|
- lib/lifeform/libraries/shoelace.rb
|
|
@@ -97,7 +99,7 @@ files:
|
|
|
97
99
|
- lib/lifeform/libraries/shoelace/submit_button.rb
|
|
98
100
|
- lib/lifeform/version.rb
|
|
99
101
|
- lifeform.gemspec
|
|
100
|
-
homepage: https://
|
|
102
|
+
homepage: https://codeberg.org/jaredwhite/lifeform
|
|
101
103
|
licenses:
|
|
102
104
|
- MIT
|
|
103
105
|
metadata:
|
|
@@ -110,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
110
112
|
requirements:
|
|
111
113
|
- - ">="
|
|
112
114
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: '3.
|
|
115
|
+
version: '3.1'
|
|
114
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
117
|
requirements:
|
|
116
118
|
- - ">="
|
|
117
119
|
- !ruby/object:Gem::Version
|
|
118
120
|
version: '0'
|
|
119
121
|
requirements: []
|
|
120
|
-
rubygems_version: 3.
|
|
122
|
+
rubygems_version: 3.4.19
|
|
121
123
|
signing_key:
|
|
122
124
|
specification_version: 4
|
|
123
125
|
summary: Component-centric form object rendering for Ruby
|