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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e07c2e8826a8660e76871f7c8796643f2ce14af6
4
- data.tar.gz: 5d890ae78955fe7e751c441eb52ef817d73822e1
3
+ metadata.gz: 49e056b4c2f65fb7db5df6f8959368489c495d85
4
+ data.tar.gz: a7faddc0568164592acd2d5c87a03ba939f257ac
5
5
  SHA512:
6
- metadata.gz: 66b87984f1027e268b7af86abb863c40f3f55b0c7bbbe1c973ad98b27a200d34961b5c8113fd2fa1c7311cd691be10140c2bc3c28d202008217b07937691c86f
7
- data.tar.gz: c1f1f2f559011007f56f9f3d3c7efebf87716c11c921f5cf039384d37db7867ee58ea5657fd9c9676a3cc4e729d1a8ea7646a4fadab9bc21a1e24c07044ce4ab
6
+ metadata.gz: 7f3bc6591e37af24cda64fb4c4680780803b84ce93f36b82576c28050847b5ce88d29f44db46b7425575c556d25bab90cb9a2a1f86c92e4ae713e5bf53013977
7
+ data.tar.gz: e91dfbcc181e96c59fb157a93483c9c7a0bd223a218babbec65f0757f9d2160a574a4a017c75f6111e41eed245649b6f0e1a05ceca9d0ec360cbda6ecc83a3c4
@@ -1,4 +1,9 @@
1
1
  # Master
2
+ # v0.2.3 2017-12-08
3
+ ### Fixed
4
+
5
+ * Improve Escape html - use for option values and optgroup labels
6
+ * Multi Select elements now mark options as selected
2
7
 
3
8
  # v0.2.2 2017-09-13
4
9
 
@@ -7,7 +7,6 @@ module Formular
7
7
  # name & value based on the attribute name
8
8
  module Control
9
9
  include Formular::Element::Module
10
- include Formular::Element::Modules::EscapeValue
11
10
 
12
11
  add_option_keys :attribute_name
13
12
 
@@ -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 HtmlEscape
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
- opts[:selected] = 'selected' if opts[:value].to_s == options[:value].to_s
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
@@ -1,3 +1,3 @@
1
1
  module Formular
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
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.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-09-13 00:00:00.000000000 Z
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.5.1
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.