forme 1.11.0 → 2.1.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/CHANGELOG +54 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +235 -209
- data/Rakefile +1 -7
- data/lib/forme/bs3.rb +18 -4
- data/lib/forme/erb.rb +13 -25
- data/lib/forme/form.rb +144 -149
- data/lib/forme/input.rb +1 -1
- data/lib/forme/rails.rb +39 -83
- data/lib/forme/raw.rb +2 -2
- data/lib/forme/tag.rb +3 -12
- data/lib/forme/template.rb +110 -0
- data/lib/forme/transformers/formatter.rb +4 -1
- data/lib/forme/transformers/helper.rb +0 -1
- data/lib/forme/transformers/inputs_wrapper.rb +4 -4
- data/lib/forme/version.rb +2 -2
- data/lib/forme.rb +15 -2
- data/lib/roda/plugins/forme.rb +1 -1
- data/lib/roda/plugins/forme_erubi_capture.rb +57 -0
- data/lib/roda/plugins/forme_route_csrf.rb +16 -34
- data/lib/roda/plugins/forme_set.rb +39 -76
- data/lib/sequel/plugins/forme.rb +40 -50
- data/lib/sequel/plugins/forme_i18n.rb +3 -1
- data/lib/sequel/plugins/forme_set.rb +3 -1
- data/spec/all.rb +1 -1
- data/spec/bs3_reference_spec.rb +18 -18
- data/spec/bs3_sequel_plugin_spec.rb +17 -17
- data/spec/bs3_spec.rb +23 -11
- data/spec/erb_helper.rb +69 -58
- data/spec/erubi_capture_helper.rb +198 -0
- data/spec/forme_spec.rb +21 -32
- data/spec/rails_integration_spec.rb +39 -25
- data/spec/roda_integration_spec.rb +118 -70
- data/spec/sequel_helper.rb +0 -1
- data/spec/sequel_i18n_helper.rb +1 -1
- data/spec/sequel_i18n_plugin_spec.rb +3 -2
- data/spec/sequel_plugin_spec.rb +29 -12
- data/spec/sequel_set_plugin_spec.rb +9 -2
- data/spec/shared_erb_specs.rb +71 -0
- data/spec/sinatra_integration_spec.rb +5 -6
- data/spec/spec_helper.rb +21 -8
- metadata +9 -7
- data/lib/forme/erb_form.rb +0 -74
- data/lib/forme/sinatra.rb +0 -17
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -172,13 +172,12 @@ files:
|
|
172
172
|
- lib/forme.rb
|
173
173
|
- lib/forme/bs3.rb
|
174
174
|
- lib/forme/erb.rb
|
175
|
-
- lib/forme/erb_form.rb
|
176
175
|
- lib/forme/form.rb
|
177
176
|
- lib/forme/input.rb
|
178
177
|
- lib/forme/rails.rb
|
179
178
|
- lib/forme/raw.rb
|
180
|
-
- lib/forme/sinatra.rb
|
181
179
|
- lib/forme/tag.rb
|
180
|
+
- lib/forme/template.rb
|
182
181
|
- lib/forme/transformers/error_handler.rb
|
183
182
|
- lib/forme/transformers/formatter.rb
|
184
183
|
- lib/forme/transformers/helper.rb
|
@@ -188,6 +187,7 @@ files:
|
|
188
187
|
- lib/forme/transformers/wrapper.rb
|
189
188
|
- lib/forme/version.rb
|
190
189
|
- lib/roda/plugins/forme.rb
|
190
|
+
- lib/roda/plugins/forme_erubi_capture.rb
|
191
191
|
- lib/roda/plugins/forme_route_csrf.rb
|
192
192
|
- lib/roda/plugins/forme_set.rb
|
193
193
|
- lib/sequel/plugins/forme.rb
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- spec/bs3_sequel_plugin_spec.rb
|
199
199
|
- spec/bs3_spec.rb
|
200
200
|
- spec/erb_helper.rb
|
201
|
+
- spec/erubi_capture_helper.rb
|
201
202
|
- spec/forme_coverage.rb
|
202
203
|
- spec/forme_spec.rb
|
203
204
|
- spec/rails_integration_spec.rb
|
@@ -207,6 +208,7 @@ files:
|
|
207
208
|
- spec/sequel_i18n_plugin_spec.rb
|
208
209
|
- spec/sequel_plugin_spec.rb
|
209
210
|
- spec/sequel_set_plugin_spec.rb
|
211
|
+
- spec/shared_erb_specs.rb
|
210
212
|
- spec/sinatra_integration_spec.rb
|
211
213
|
- spec/spec_helper.rb
|
212
214
|
homepage: http://github.com/jeremyevans/forme
|
@@ -216,7 +218,7 @@ metadata:
|
|
216
218
|
bug_tracker_uri: https://github.com/jeremyevans/forme/issues
|
217
219
|
changelog_uri: http://forme.jeremyevans.net/files/CHANGELOG.html
|
218
220
|
documentation_uri: http://forme.jeremyevans.net
|
219
|
-
mailing_list_uri: https://
|
221
|
+
mailing_list_uri: https://github.com/jeremyevans/forme/discussions
|
220
222
|
source_code_uri: https://github.com/jeremyevans/forme
|
221
223
|
post_install_message:
|
222
224
|
rdoc_options:
|
@@ -233,14 +235,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
235
|
requirements:
|
234
236
|
- - ">="
|
235
237
|
- !ruby/object:Gem::Version
|
236
|
-
version:
|
238
|
+
version: 1.9.2
|
237
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
240
|
requirements:
|
239
241
|
- - ">="
|
240
242
|
- !ruby/object:Gem::Version
|
241
243
|
version: '0'
|
242
244
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
245
|
+
rubygems_version: 3.3.7
|
244
246
|
signing_key:
|
245
247
|
specification_version: 4
|
246
248
|
summary: HTML forms library
|
data/lib/forme/erb_form.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
|
3
|
-
require 'forme'
|
4
|
-
|
5
|
-
module Forme
|
6
|
-
module ERB
|
7
|
-
# Subclass used when using Forme ERB integration.
|
8
|
-
# Handles integrating into the view template so that
|
9
|
-
# methods with blocks can inject strings into the output.
|
10
|
-
class Form < ::Forme::Form
|
11
|
-
# Template output object, where serialized output gets
|
12
|
-
# injected.
|
13
|
-
attr_reader :output
|
14
|
-
|
15
|
-
# Set the template output object when initializing.
|
16
|
-
def initialize(*)
|
17
|
-
super
|
18
|
-
@output = @opts[:output] ? @opts[:output] : String.new
|
19
|
-
end
|
20
|
-
|
21
|
-
# Serialize the tag and inject it into the output.
|
22
|
-
def emit(tag)
|
23
|
-
output << tag.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
# Capture the inside of the inputs, injecting it into the template
|
27
|
-
# if a block is given, or returning it as a string if not.
|
28
|
-
def inputs(*a, &block)
|
29
|
-
if block
|
30
|
-
capture(block){super}
|
31
|
-
else
|
32
|
-
capture{super}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Capture the inside of the form, injecting it into the template if
|
37
|
-
# a block is given, or returning it as a string if not.
|
38
|
-
def form(*a, &block)
|
39
|
-
if block
|
40
|
-
capture(block){super}
|
41
|
-
else
|
42
|
-
super
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# If a block is given, inject an opening tag into the
|
47
|
-
# output, inject any given children into the output, yield to the
|
48
|
-
# block, inject a closing tag into the output.
|
49
|
-
# If a block is not given, just return the tag created.
|
50
|
-
def tag(type, attr={}, children=[], &block)
|
51
|
-
tag = _tag(type, attr, children)
|
52
|
-
if block
|
53
|
-
capture(block) do
|
54
|
-
emit(serialize_open(tag))
|
55
|
-
Array(tag.children).each{|c| emit(c)}
|
56
|
-
yield self
|
57
|
-
emit(serialize_close(tag))
|
58
|
-
end
|
59
|
-
else
|
60
|
-
tag
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def capture(block=String.new) # :nodoc:
|
65
|
-
buf_was, @output = @output, block.is_a?(Proc) ? (eval("@_out_buf", block.binding) || @output) : block
|
66
|
-
yield
|
67
|
-
ret = @output
|
68
|
-
@output = buf_was
|
69
|
-
ret
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
data/lib/forme/sinatra.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
|
3
|
-
require 'forme/erb'
|
4
|
-
|
5
|
-
module Forme
|
6
|
-
# For backwards compatibility only. New code should
|
7
|
-
# require 'forme/erb' and include the Forme::ERB::Helper
|
8
|
-
# class:
|
9
|
-
#
|
10
|
-
# helpers Forme::ERB::Helper
|
11
|
-
module Sinatra
|
12
|
-
ERB = Forme::ERB::Helper
|
13
|
-
Erubis = ERB
|
14
|
-
Form = Forme::ERB::Form
|
15
|
-
HIDDEN_TAGS = Forme::ERB::HIDDEN_TAGS
|
16
|
-
end
|
17
|
-
end
|