formular 0.2.2 → 0.2.3
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.md +5 -0
- data/lib/formular/element/modules/control.rb +0 -1
- data/lib/formular/elements.rb +18 -6
- data/lib/formular/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49e056b4c2f65fb7db5df6f8959368489c495d85
|
4
|
+
data.tar.gz: a7faddc0568164592acd2d5c87a03ba939f257ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f3bc6591e37af24cda64fb4c4680780803b84ce93f36b82576c28050847b5ce88d29f44db46b7425575c556d25bab90cb9a2a1f86c92e4ae713e5bf53013977
|
7
|
+
data.tar.gz: e91dfbcc181e96c59fb157a93483c9c7a0bd223a218babbec65f0757f9d2160a574a4a017c75f6111e41eed245649b6f0e1a05ceca9d0ec360cbda6ecc83a3c4
|
data/CHANGELOG.md
CHANGED
data/lib/formular/elements.rb
CHANGED
@@ -16,7 +16,6 @@ module Formular
|
|
16
16
|
Wrapped = Class.new(Formular::Element) { include Formular::Element::Modules::Wrapped }
|
17
17
|
|
18
18
|
# define some base classes to build from or easily use elsewhere
|
19
|
-
OptGroup = Class.new(Container) { tag :optgroup }
|
20
19
|
Fieldset = Class.new(Container) { tag :fieldset }
|
21
20
|
Legend = Class.new(Container) { tag :legend }
|
22
21
|
Div = Class.new(Container) { tag :div }
|
@@ -24,13 +23,19 @@ module Formular
|
|
24
23
|
Span = Class.new(Container) { tag :span }
|
25
24
|
Small = Class.new(Container) { tag :small }
|
26
25
|
|
26
|
+
class OptGroup < Container
|
27
|
+
include HtmlEscape
|
28
|
+
tag :optgroup
|
29
|
+
process_option :label, :html_escape
|
30
|
+
end
|
31
|
+
|
27
32
|
class Option < Container
|
28
33
|
tag :option
|
29
34
|
include Formular::Element::Modules::EscapeValue
|
30
35
|
end
|
31
36
|
|
32
|
-
|
33
37
|
class Hidden < Control
|
38
|
+
include Formular::Element::Modules::EscapeValue
|
34
39
|
tag :input
|
35
40
|
set_default :type, 'hidden'
|
36
41
|
|
@@ -162,17 +167,17 @@ module Formular
|
|
162
167
|
end # class Submit
|
163
168
|
|
164
169
|
class Button < Container
|
170
|
+
include Formular::Element::Modules::EscapeValue
|
165
171
|
include Formular::Element::Modules::Control
|
166
172
|
|
167
173
|
tag :button
|
168
174
|
end # class Button
|
169
175
|
|
170
176
|
class Input < Control
|
171
|
-
include
|
177
|
+
include Formular::Element::Modules::EscapeValue
|
172
178
|
|
173
179
|
tag :input
|
174
180
|
set_default :type, 'text'
|
175
|
-
process_option :value, :html_escape
|
176
181
|
|
177
182
|
html { closed_start_tag }
|
178
183
|
end # class Input
|
@@ -262,12 +267,19 @@ module Formular
|
|
262
267
|
{}
|
263
268
|
end
|
264
269
|
|
265
|
-
opts[:value] = item.send(options[:value_method])
|
270
|
+
opts[:value] = html_escape(item.send(options[:value_method]))
|
266
271
|
opts[:content] = item.send(options[:label_method])
|
267
|
-
|
272
|
+
|
273
|
+
opts[:selected] = 'selected' if item_is_selected(opts[:value], options[:value], options[:multiple])
|
268
274
|
|
269
275
|
Formular::Element::Option.new(opts).to_s
|
270
276
|
end
|
277
|
+
|
278
|
+
def item_is_selected(option_val, current_val, multiple)
|
279
|
+
return option_val == current_val.to_s unless multiple && current_val.is_a?(Array)
|
280
|
+
|
281
|
+
current_val.map(&:to_s).include?(option_val) # TODO Perf improvement here - do we need the map?
|
282
|
+
end
|
271
283
|
end # class Select
|
272
284
|
|
273
285
|
class Checkbox < Control
|
data/lib/formular/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: declarative
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
224
|
+
rubygems_version: 2.4.6
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Form builder based on Cells. Fast, Furious, and Framework-Agnostic.
|