forme 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/README.rdoc +28 -2
- data/lib/forme/bs3.rb +1 -1
- data/lib/forme/transformers/formatter.rb +5 -3
- data/lib/forme/transformers/serializer.rb +1 -1
- data/lib/forme/version.rb +1 -1
- data/lib/forme.rb +4 -10
- data/lib/roda/plugins/forme_erubi_capture_block.rb +45 -0
- data/lib/roda/plugins/forme_set.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0078a295325f1880c32a870466a7e280a0cd324e2f8bf91ea81125bf557d225
|
4
|
+
data.tar.gz: 120e19dde7e39176a4693a4ab46f7f1c2f4d86265f3de4946af6a1d40f5fd524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f13bb7fdfaf90be6af18cc67403d4e36f963c6258eeb49bbc4579b356534172fa4d25380f032ef7a80954f532de3a63f67e3ad3a985c0225d4d21db0245fe387
|
7
|
+
data.tar.gz: 6ec1d4cbee834565239953a12b826b9b190c4f80901b6dc559954c7414889a1c0691e3a16b25dd5d2176a079ae3826a3b9e13bb6c23e323979046af98288208f
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 2.6.0 (2024-06-18)
|
2
|
+
|
3
|
+
* Add Roda forme_erubi_capture_block plugin to support erubi/capture_block <%= form do %> <% end %> tags (jeremyevans)
|
4
|
+
|
5
|
+
* Support :hr as select option value to use a hr tag instead of an option tag (jeremyevans)
|
6
|
+
|
7
|
+
* Support maxlength and minlength options as attributes for textareas (jeremyevans)
|
8
|
+
|
9
|
+
* Support minlength option as attribute for text inputs (jeremyevans)
|
10
|
+
|
1
11
|
=== 2.5.0 (2024-02-13)
|
2
12
|
|
3
13
|
* Add hidden inputs to work with formaction/formmethod support in Roda 3.77+ route_csrf plugin (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -615,8 +615,8 @@ internally). +forme_parse+ returns a hash with the following keys:
|
|
615
615
|
check that the submitted values for associated objects match one of the
|
616
616
|
options for the input in the form.
|
617
617
|
|
618
|
-
It is possible to use +forme_set+ for the
|
619
|
-
|
618
|
+
It is possible to use +forme_set+ for the forms it can handle, and use +forme_parse+ and
|
619
|
+
+set_fields+ for other forms.
|
620
620
|
|
621
621
|
=== Roda forme_set plugin
|
622
622
|
|
@@ -792,6 +792,7 @@ Forme ships with multiple Roda plugins
|
|
792
792
|
* forme_set (discussed above)
|
793
793
|
* forme
|
794
794
|
* forme_route_csrf
|
795
|
+
* forme_erubi_capture_block
|
795
796
|
* forme_erubi_capture
|
796
797
|
|
797
798
|
== forme_route_csrf and forme plugins
|
@@ -837,6 +838,26 @@ The forme plugin does not require any csrf plugin, but will transparently use
|
|
837
838
|
Rack::Csrf if it is available. If Rack::Csrf is available a CSRF tag if the form's
|
838
839
|
method is +POST+, with no configuration ability.
|
839
840
|
|
841
|
+
== forme_erubi_capture_block plugin
|
842
|
+
|
843
|
+
The forme_erubi_capture_block plugin builds on the forme_route_csrf plugin, but it supports
|
844
|
+
the erubi/capture_block engine, which allows this syntax:
|
845
|
+
|
846
|
+
<%= form(@obj, :action=>'/foo') do |f| %>
|
847
|
+
<%= f.input(:field) %>
|
848
|
+
<%= f.tag(:fieldset) do %>
|
849
|
+
<%= f.input(:field_two) %>
|
850
|
+
<% end %>
|
851
|
+
<% end %>
|
852
|
+
|
853
|
+
If you use the forme_erubi_capture)block plugin, you need to manually set Roda to use the
|
854
|
+
erubi/capture_block engine, which you can do via:
|
855
|
+
|
856
|
+
require 'erubi/capture_block'
|
857
|
+
app.plugin :render, :engine_opts=>{'erb'=>{:engine_class=>Erubi::CaptureBlockEngine}}
|
858
|
+
|
859
|
+
The forme_erubi_capture plugin requires Erubi 1.13.0+.
|
860
|
+
|
840
861
|
== forme_erubi_capture plugin
|
841
862
|
|
842
863
|
The forme_erubi_capture plugin builds on the forme_route_csrf plugin, but it supports
|
@@ -982,6 +1003,8 @@ Creates a select tag, containing option tags specified by the :options option.
|
|
982
1003
|
array, uses the first entry of the array as the text of the option, and
|
983
1004
|
the last entry of the array as the value of the option. If the last entry
|
984
1005
|
of the array is a hash, uses the hash as the attributes for the option.
|
1006
|
+
If the option value is +:hr+, uses an hr tag (allowed in recent versions of
|
1007
|
+
the HTML standard).
|
985
1008
|
:selected :: The value that should be selected. Any options that are equal to
|
986
1009
|
this value (or included in this value if a multiple select box),
|
987
1010
|
are set to selected.
|
@@ -1013,6 +1036,8 @@ Creates a textarea tag. Options:
|
|
1013
1036
|
|
1014
1037
|
:cols :: The number of columns in the text area.
|
1015
1038
|
:rows :: The number of rows in the text area.
|
1039
|
+
:maxlength :: Use the maxlength attribute on the tag
|
1040
|
+
:minlength :: Use the minlength attribute on the tag
|
1016
1041
|
|
1017
1042
|
== all others
|
1018
1043
|
|
@@ -1021,6 +1046,7 @@ as text and password, as well as newer HTML5 inputs such as number or email. Opt
|
|
1021
1046
|
|
1022
1047
|
:size :: Uses the size attribute on the tag
|
1023
1048
|
:maxlength :: Use the maxlength attribute on the tag
|
1049
|
+
:minlength :: Use the minlength attribute on the tag
|
1024
1050
|
|
1025
1051
|
== Form options
|
1026
1052
|
|
data/lib/forme/bs3.rb
CHANGED
@@ -356,7 +356,7 @@ module Forme
|
|
356
356
|
case tag.attr[:type].to_sym
|
357
357
|
when :checkbox, :radio, :hidden
|
358
358
|
# .form-control class causes rendering problems, so remove if found
|
359
|
-
tag.attr[:class].gsub
|
359
|
+
tag.attr[:class] = tag.attr[:class].gsub(/\s*form-control\s*/,'') if tag.attr[:class]
|
360
360
|
tag.attr[:class] = nil if tag.attr[:class] && tag.attr[:class].empty?
|
361
361
|
|
362
362
|
when :file
|
@@ -178,7 +178,7 @@ module Forme
|
|
178
178
|
# with the type attribute set to input.
|
179
179
|
def _format_input(type)
|
180
180
|
@attr[:type] = type
|
181
|
-
copy_options_to_attributes([:size, :maxlength])
|
181
|
+
copy_options_to_attributes([:size, :maxlength, :minlength])
|
182
182
|
tag(:input)
|
183
183
|
end
|
184
184
|
|
@@ -277,7 +277,7 @@ module Forme
|
|
277
277
|
# Formats a textarea. Respects the following options:
|
278
278
|
# :value :: Sets value as the child of the textarea.
|
279
279
|
def format_textarea
|
280
|
-
copy_options_to_attributes([:cols, :rows])
|
280
|
+
copy_options_to_attributes([:cols, :rows, :maxlength, :minlength])
|
281
281
|
if val = @attr.delete(:value)
|
282
282
|
tag(:textarea, @attr, [val])
|
283
283
|
else
|
@@ -452,7 +452,9 @@ module Forme
|
|
452
452
|
|
453
453
|
os.map do |x|
|
454
454
|
attr = {}
|
455
|
-
if
|
455
|
+
if x == :hr
|
456
|
+
next form._tag(:hr, {})
|
457
|
+
elsif tm
|
456
458
|
text = x.send(tm)
|
457
459
|
val = x.send(vm) if vm
|
458
460
|
elsif x.is_a?(Array)
|
@@ -9,7 +9,7 @@ module Forme
|
|
9
9
|
Forme.register_transformer(:serializer, :default, new)
|
10
10
|
|
11
11
|
# Which tags are self closing (such tags ignore children).
|
12
|
-
SELF_CLOSING = [:img, :input]
|
12
|
+
SELF_CLOSING = [:img, :input, :hr]
|
13
13
|
|
14
14
|
# Serialize the tag object to an html string. Supports +Tag+ instances,
|
15
15
|
# +Input+ instances (recursing into +call+ with the result of formatting the input),
|
data/lib/forme/version.rb
CHANGED
data/lib/forme.rb
CHANGED
@@ -25,16 +25,10 @@ module Forme
|
|
25
25
|
rescue LoadError
|
26
26
|
ESCAPE_TABLE = {'&' => '&', '<' => '<', '>' => '>', '"' => '"', "'" => '''}.freeze
|
27
27
|
ESCAPE_TABLE.each_value(&:freeze)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
|
33
|
-
end
|
34
|
-
else
|
35
|
-
def self.h(value)
|
36
|
-
value.to_s.gsub(/[&<>"']/){|s| ESCAPE_TABLE[s]}
|
37
|
-
end
|
28
|
+
# Escape the following characters with their HTML/XML
|
29
|
+
# equivalents.
|
30
|
+
def self.h(value)
|
31
|
+
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
|
38
32
|
end
|
39
33
|
end
|
40
34
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require_relative '../../forme/template'
|
4
|
+
|
5
|
+
class Roda
|
6
|
+
module RodaPlugins
|
7
|
+
module FormeErubiCaptureBlock
|
8
|
+
def self.load_dependencies(app)
|
9
|
+
app.plugin :forme_route_csrf
|
10
|
+
end
|
11
|
+
|
12
|
+
class Form < ::Forme::Template::Form
|
13
|
+
%w'inputs tag subform'.each do |meth|
|
14
|
+
class_eval(<<-END, __FILE__, __LINE__+1)
|
15
|
+
def #{meth}(*)
|
16
|
+
if block_given?
|
17
|
+
@scope.instance_variable_get(@scope.render_opts[:template_opts][:outvar]).capture{super}
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
END
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module InstanceMethods
|
27
|
+
def _forme_form(obj, attr, opts, &block)
|
28
|
+
if block && opts[:emit] != false
|
29
|
+
instance_variable_get(render_opts[:template_opts][:outvar]).capture{super}
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def _forme_form_class
|
38
|
+
Form
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
register_plugin(:forme_erubi_capture_block, FormeErubiCaptureBlock)
|
44
|
+
end
|
45
|
+
end
|
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: 2.
|
4
|
+
version: 2.6.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: 2024-
|
11
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/forme/version.rb
|
204
204
|
- lib/roda/plugins/forme.rb
|
205
205
|
- lib/roda/plugins/forme_erubi_capture.rb
|
206
|
+
- lib/roda/plugins/forme_erubi_capture_block.rb
|
206
207
|
- lib/roda/plugins/forme_route_csrf.rb
|
207
208
|
- lib/roda/plugins/forme_set.rb
|
208
209
|
- lib/sequel/plugins/forme.rb
|
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
240
|
- !ruby/object:Gem::Version
|
240
241
|
version: '0'
|
241
242
|
requirements: []
|
242
|
-
rubygems_version: 3.5.
|
243
|
+
rubygems_version: 3.5.9
|
243
244
|
signing_key:
|
244
245
|
specification_version: 4
|
245
246
|
summary: HTML forms library
|