trenni-formatters 2.12.2 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fc81bd7424d62a51946525bfadb198b184223b85f39924b090c4917866e4e07
4
- data.tar.gz: 2b68b00618ebff45b414dd7f4cd29eb770cdc4093ce0e80738a2b20dcba60377
3
+ metadata.gz: a733cfc023aed3ce78ce8278b8d4ef57ee05215440d5bcf0304280115b002cc5
4
+ data.tar.gz: 374dade3208878129d786ef7917085ee5f05e5df50a62eb2d969ce970be944b3
5
5
  SHA512:
6
- metadata.gz: bb61c211734823ed5d5c198532d892bd881309c90799cdd939d025e0edc59582fcc11b92292c8cbfeaf748fc60ea81c883967aaf58c0f46bcd9067ba5c362bbd
7
- data.tar.gz: 2fc540df7f46b5dd4209517143fbe50d603cfd9857000c86906bc50c2c0302d8ae467cdbc8758e00f6360ba3e6dd99ca79bb9b4a232af11e9ab8f9cacc18e6dd
6
+ metadata.gz: a6663a34484d4fdc67cc9771df53959941e8c514bf03b752bb2c63680ac1e041ee7da4c95a6d8bb45430dd230093cc9b5911c1fef394dc6d179fafd4e9632121
7
+ data.tar.gz: a469d0252fdf4dd7fecd68048350e68a938bb28bbfe3347b47d2c04c39cc40fd7f5fd6dc3477c05d7eb360190f58c526d9fc900930183868ff3cadc2538486b6
@@ -119,9 +119,8 @@ module Trenni
119
119
 
120
120
  def element(klass, **options, &block)
121
121
  options = @options.merge(**options)
122
- buffer = Trenni::Template.buffer(block.binding)
123
122
 
124
- buffer << Builder.fragment do |builder|
123
+ Builder.fragment(block&.binding) do |builder|
125
124
  builder.inline(:dt) do
126
125
  builder.text title_for(**options)
127
126
  end
@@ -126,7 +126,7 @@ module Trenni
126
126
  options = @options.merge(**options)
127
127
  buffer = Trenni::Template.buffer(block.binding)
128
128
 
129
- buffer << Builder.fragment do |builder|
129
+ Builder.fragment(buffer) do |builder|
130
130
  builder.inline(:label) do
131
131
  builder.inline(:span) do
132
132
  builder.text title_for(**options)
@@ -75,11 +75,17 @@ module Trenni
75
75
  }
76
76
  end
77
77
 
78
- def item(builder = nil, **options)
78
+ def item(**options, &block)
79
79
  options[:field] ||= 'id'
80
80
 
81
- Builder.fragment(builder) do |builder|
82
- builder.inline(:option, option_attributes_for(**options)) {builder.text title_for(**options)}
81
+ Builder.fragment(block&.binding || @builder) do |builder|
82
+ builder.inline(:option, option_attributes_for(**options)) do
83
+ if block_given?
84
+ builder.capture(self, &block)
85
+ else
86
+ builder.text title_for(**options)
87
+ end
88
+ end
83
89
  end
84
90
  end
85
91
 
@@ -101,14 +107,12 @@ module Trenni
101
107
  end
102
108
 
103
109
  def group(**options, &block)
104
- Builder.fragment(@builder) do |builder|
105
- builder.tag :optgroup, group_attributes_for(**options) do
106
- if options[:optional]
107
- item(@builder, title: optional_title_for(**options), value: nil)
108
- end
109
-
110
- builder.capture(&block)
110
+ @builder.tag :optgroup, group_attributes_for(**options) do
111
+ if options[:optional]
112
+ item(title: optional_title_for(**options), value: nil)
111
113
  end
114
+
115
+ @builder.capture(&block)
112
116
  end
113
117
  end
114
118
 
@@ -131,7 +135,7 @@ module Trenni
131
135
  Builder.fragment(@builder) do |builder|
132
136
  builder.tag :select, select_attributes_for(**@options) do
133
137
  if self.optional?
134
- item(builder, title: optional_title_for(**@options), value: nil)
138
+ builder << item(title: optional_title_for(**@options), value: nil)
135
139
  end
136
140
 
137
141
  builder.capture(self, &block)
@@ -72,8 +72,8 @@ module Trenni
72
72
  }
73
73
  end
74
74
 
75
- def item(builder = nil, **options, &block)
76
- Builder.fragment(builder) do |builder|
75
+ def item(**options, &block)
76
+ Builder.fragment do |builder|
77
77
  builder.tag :tr do
78
78
  builder.inline(:td, :class => :handle) do
79
79
  builder.tag :input, radio_attributes_for(**options)
@@ -87,7 +87,7 @@ module Trenni
87
87
  end
88
88
  end
89
89
  end
90
- end >> block
90
+ end
91
91
  end
92
92
 
93
93
  def optional_title_for(**options)
@@ -107,7 +107,7 @@ module Trenni
107
107
  builder.tag :table do
108
108
  builder.tag :tbody do
109
109
  if self.optional?
110
- item(builder, title: optional_title_for(**@options), value: nil)
110
+ builder << item(title: optional_title_for(**@options), value: nil)
111
111
  end
112
112
 
113
113
  builder.capture(self, &block)
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Trenni
24
24
  module Formatters
25
- VERSION = "2.12.2"
25
+ VERSION = "2.13.0"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trenni-formatters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.2
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-06 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mapping
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.4'
33
+ version: '3.12'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.4'
40
+ version: '3.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bake
43
43
  requirement: !ruby/object:Gem::Requirement