view_component 2.34.0 → 2.35.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/vendor/prism.css +196 -0
- data/app/assets/vendor/prism.min.js +12 -0
- data/app/helpers/preview_helper.rb +19 -0
- data/app/views/view_components/_preview_source.html.erb +17 -0
- data/app/views/view_components/preview.html.erb +6 -2
- data/{CHANGELOG.md → docs/CHANGELOG.md} +74 -2
- data/lib/rails/generators/abstract_generator.rb +29 -0
- data/lib/rails/generators/component/component_generator.rb +5 -5
- data/lib/rails/generators/erb/component_generator.rb +7 -16
- data/lib/rails/generators/haml/component_generator.rb +6 -16
- data/lib/rails/generators/slim/component_generator.rb +6 -16
- data/lib/view_component.rb +1 -0
- data/lib/view_component/base.rb +94 -72
- data/lib/view_component/collection.rb +2 -1
- data/lib/view_component/compile_cache.rb +1 -0
- data/lib/view_component/compiler.rb +53 -49
- data/lib/view_component/content_areas.rb +50 -0
- data/lib/view_component/engine.rb +6 -0
- data/lib/view_component/preview.rb +14 -7
- data/lib/view_component/previewable.rb +16 -18
- data/lib/view_component/slot_v2.rb +28 -27
- data/lib/view_component/slotable.rb +2 -1
- data/lib/view_component/slotable_v2.rb +19 -18
- data/lib/view_component/translatable.rb +6 -5
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component/with_content_helper.rb +1 -1
- data/lib/yard/mattr_accessor_handler.rb +19 -0
- metadata +74 -39
@@ -52,7 +52,7 @@ module ViewComponent
|
|
52
52
|
|
53
53
|
def scope_data(data)
|
54
54
|
@i18n_scope.reverse_each do |part|
|
55
|
-
data = { part => data}
|
55
|
+
data = { part => data }
|
56
56
|
end
|
57
57
|
data
|
58
58
|
end
|
@@ -70,9 +70,10 @@ module ViewComponent
|
|
70
70
|
key = key&.to_s unless key.is_a?(String)
|
71
71
|
key = "#{i18n_scope}#{key}" if key.start_with?(".")
|
72
72
|
|
73
|
-
translated =
|
74
|
-
|
75
|
-
|
73
|
+
translated =
|
74
|
+
catch(:exception) do
|
75
|
+
i18n_backend.translate(locale, key, options)
|
76
|
+
end
|
76
77
|
|
77
78
|
# Fallback to the global translations
|
78
79
|
if translated.is_a? ::I18n::MissingTranslation
|
@@ -80,7 +81,7 @@ module ViewComponent
|
|
80
81
|
end
|
81
82
|
|
82
83
|
if HTML_SAFE_TRANSLATION_KEY.match?(key)
|
83
|
-
translated = translated.html_safe
|
84
|
+
translated = translated.html_safe # rubocop:disable Rails/OutputSafety
|
84
85
|
end
|
85
86
|
|
86
87
|
translated
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
# YARD Handler to parse `mattr_accessor` calls.
|
5
|
+
class MattrAccessorHandler < YARD::Handlers::Ruby::Base
|
6
|
+
handles method_call(:mattr_accessor)
|
7
|
+
namespace_only
|
8
|
+
|
9
|
+
process do
|
10
|
+
name = statement.parameters.first.jump(:tstring_content, :ident).source
|
11
|
+
object = YARD::CodeObjects::MethodObject.new(namespace, name)
|
12
|
+
register(object)
|
13
|
+
parse_block(statement.last, owner: object)
|
14
|
+
|
15
|
+
object.dynamic = true
|
16
|
+
object[:mattr_accessor] = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,21 @@ dependencies:
|
|
29
29
|
version: 5.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: method_source
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: benchmark-ips
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,47 +59,47 @@ dependencies:
|
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: 2.8.2
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
62
|
+
name: better_html
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - "~>"
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1
|
67
|
+
version: '1'
|
54
68
|
type: :development
|
55
69
|
prerelease: false
|
56
70
|
version_requirements: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
58
72
|
- - "~>"
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version: '1
|
74
|
+
version: '1'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
76
|
+
name: bundler
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
81
|
+
version: '2.2'
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
88
|
+
version: '2.2'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
90
|
+
name: erb_lint
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
|
-
- -
|
93
|
+
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
95
|
+
version: 0.0.37
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
|
-
- -
|
100
|
+
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
102
|
+
version: 0.0.37
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: haml
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,75 +115,75 @@ dependencies:
|
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '5'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
118
|
+
name: jbuilder
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - "~>"
|
108
122
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
123
|
+
version: '2'
|
110
124
|
type: :development
|
111
125
|
prerelease: false
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
128
|
- - "~>"
|
115
129
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
130
|
+
version: '2'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
132
|
+
name: minitest
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
120
134
|
requirements:
|
121
|
-
- -
|
135
|
+
- - '='
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
137
|
+
version: 5.6.0
|
124
138
|
type: :development
|
125
139
|
prerelease: false
|
126
140
|
version_requirements: !ruby/object:Gem::Requirement
|
127
141
|
requirements:
|
128
|
-
- -
|
142
|
+
- - '='
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
144
|
+
version: 5.6.0
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
146
|
+
name: pry
|
133
147
|
requirement: !ruby/object:Gem::Requirement
|
134
148
|
requirements:
|
135
149
|
- - "~>"
|
136
150
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
151
|
+
version: '0.13'
|
138
152
|
type: :development
|
139
153
|
prerelease: false
|
140
154
|
version_requirements: !ruby/object:Gem::Requirement
|
141
155
|
requirements:
|
142
156
|
- - "~>"
|
143
157
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
158
|
+
version: '0.13'
|
145
159
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
160
|
+
name: rake
|
147
161
|
requirement: !ruby/object:Gem::Requirement
|
148
162
|
requirements:
|
149
|
-
- -
|
163
|
+
- - "~>"
|
150
164
|
- !ruby/object:Gem::Version
|
151
|
-
version: '0
|
165
|
+
version: '13.0'
|
152
166
|
type: :development
|
153
167
|
prerelease: false
|
154
168
|
version_requirements: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
|
-
- -
|
170
|
+
- - "~>"
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0
|
172
|
+
version: '13.0'
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: rubocop-github
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
162
176
|
requirements:
|
163
177
|
- - "~>"
|
164
178
|
- !ruby/object:Gem::Version
|
165
|
-
version: 0.
|
179
|
+
version: 0.16.1
|
166
180
|
type: :development
|
167
181
|
prerelease: false
|
168
182
|
version_requirements: !ruby/object:Gem::Requirement
|
169
183
|
requirements:
|
170
184
|
- - "~>"
|
171
185
|
- !ruby/object:Gem::Version
|
172
|
-
version: 0.
|
186
|
+
version: 0.16.1
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: simplecov
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,19 +213,19 @@ dependencies:
|
|
199
213
|
- !ruby/object:Gem::Version
|
200
214
|
version: 0.7.2
|
201
215
|
- !ruby/object:Gem::Dependency
|
202
|
-
name:
|
216
|
+
name: slim
|
203
217
|
requirement: !ruby/object:Gem::Requirement
|
204
218
|
requirements:
|
205
219
|
- - "~>"
|
206
220
|
- !ruby/object:Gem::Version
|
207
|
-
version: '0
|
221
|
+
version: '4.0'
|
208
222
|
type: :development
|
209
223
|
prerelease: false
|
210
224
|
version_requirements: !ruby/object:Gem::Requirement
|
211
225
|
requirements:
|
212
226
|
- - "~>"
|
213
227
|
- !ruby/object:Gem::Version
|
214
|
-
version: '0
|
228
|
+
version: '4.0'
|
215
229
|
- !ruby/object:Gem::Dependency
|
216
230
|
name: yard
|
217
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,6 +240,20 @@ dependencies:
|
|
226
240
|
- - "~>"
|
227
241
|
- !ruby/object:Gem::Version
|
228
242
|
version: 0.9.25
|
243
|
+
- !ruby/object:Gem::Dependency
|
244
|
+
name: yard-activesupport-concern
|
245
|
+
requirement: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ">="
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
250
|
+
type: :development
|
251
|
+
prerelease: false
|
252
|
+
version_requirements: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ">="
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
229
257
|
description:
|
230
258
|
email:
|
231
259
|
- opensource+view_component@github.com
|
@@ -233,14 +261,19 @@ executables: []
|
|
233
261
|
extensions: []
|
234
262
|
extra_rdoc_files: []
|
235
263
|
files:
|
236
|
-
- CHANGELOG.md
|
237
264
|
- LICENSE.txt
|
238
265
|
- README.md
|
266
|
+
- app/assets/vendor/prism.css
|
267
|
+
- app/assets/vendor/prism.min.js
|
239
268
|
- app/controllers/view_components_controller.rb
|
269
|
+
- app/helpers/preview_helper.rb
|
240
270
|
- app/views/test_mailer/test_email.html.erb
|
271
|
+
- app/views/view_components/_preview_source.html.erb
|
241
272
|
- app/views/view_components/index.html.erb
|
242
273
|
- app/views/view_components/preview.html.erb
|
243
274
|
- app/views/view_components/previews.html.erb
|
275
|
+
- docs/CHANGELOG.md
|
276
|
+
- lib/rails/generators/abstract_generator.rb
|
244
277
|
- lib/rails/generators/component/USAGE
|
245
278
|
- lib/rails/generators/component/component_generator.rb
|
246
279
|
- lib/rails/generators/component/templates/component.rb.tt
|
@@ -262,6 +295,7 @@ files:
|
|
262
295
|
- lib/view_component/compile_cache.rb
|
263
296
|
- lib/view_component/compiler.rb
|
264
297
|
- lib/view_component/component_error.rb
|
298
|
+
- lib/view_component/content_areas.rb
|
265
299
|
- lib/view_component/engine.rb
|
266
300
|
- lib/view_component/instrumentation.rb
|
267
301
|
- lib/view_component/preview.rb
|
@@ -283,6 +317,7 @@ files:
|
|
283
317
|
- lib/view_component/translatable.rb
|
284
318
|
- lib/view_component/version.rb
|
285
319
|
- lib/view_component/with_content_helper.rb
|
320
|
+
- lib/yard/mattr_accessor_handler.rb
|
286
321
|
homepage: https://github.com/github/view_component
|
287
322
|
licenses:
|
288
323
|
- MIT
|
@@ -296,14 +331,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
296
331
|
requirements:
|
297
332
|
- - ">="
|
298
333
|
- !ruby/object:Gem::Version
|
299
|
-
version: 2.
|
334
|
+
version: 2.4.0
|
300
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
301
336
|
requirements:
|
302
337
|
- - ">="
|
303
338
|
- !ruby/object:Gem::Version
|
304
339
|
version: '0'
|
305
340
|
requirements: []
|
306
|
-
rubygems_version: 3.
|
341
|
+
rubygems_version: 3.1.4
|
307
342
|
signing_key:
|
308
343
|
specification_version: 4
|
309
344
|
summary: View components for Rails
|