view_component 2.43.1 → 2.44.0
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.
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/docs/CHANGELOG.md +46 -0
- data/lib/view_component/base.rb +5 -13
- data/lib/view_component/engine.rb +9 -0
- data/lib/view_component/previewable.rb +8 -0
- data/lib/view_component/version.rb +2 -2
- data/lib/view_component.rb +1 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2542c18f4fbd3071c18fb27d8edb563021ad201fa5cc4d0c02fb8190918b6920
|
4
|
+
data.tar.gz: 7c7fb2ef2a79ed3816655cd8f27a52248fe0181957487a9b0297968914034c9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e43d3b7398bd838b25e87a566ce82229e82343f64a9f70230b90d4eb2b0afdc8e0ffda355acd032877d0751082e3e4342ecd53955011de89ea1ce341c6b7a80
|
7
|
+
data.tar.gz: 3d90591c1d4d3cbff9d8e4c7dd1f94015ddce95e62f8284586dda63da99311609c3558fd353f0cf3c6b8c58f4c9a0b18f0fa91e60aa2275e57284cb2e10bff4a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<img src="/docs/logo/
|
1
|
+
<img src="/docs/logo/github-readme-logo.svg" alt="ViewComponent logo" width="400">
|
2
2
|
|
3
3
|
A framework for building reusable, testable & encapsulated view components in Ruby on Rails.
|
4
4
|
|
data/docs/CHANGELOG.md
CHANGED
@@ -7,6 +7,52 @@ title: Changelog
|
|
7
7
|
|
8
8
|
## main
|
9
9
|
|
10
|
+
## 2.44.0
|
11
|
+
|
12
|
+
* Rename internal accessor to use private naming.
|
13
|
+
|
14
|
+
*Joel Hawksley*, *Blake Williams*, *Cameron Dutro*
|
15
|
+
|
16
|
+
* Add Github repo link to docs website header.
|
17
|
+
|
18
|
+
*Hans Lemuet*
|
19
|
+
|
20
|
+
* Change logo in README for dark theme readability.
|
21
|
+
|
22
|
+
*Dylan Smith*
|
23
|
+
|
24
|
+
* Add Litmus to users list.
|
25
|
+
|
26
|
+
*Dylan Smith*
|
27
|
+
|
28
|
+
* Add @dylanatsmith as codeowner of the ViewComponent logo and member of committers team.
|
29
|
+
|
30
|
+
*Joel Hawksley*
|
31
|
+
|
32
|
+
* Autoload `CompileCache`, which is optionally called in `engine.rb`.
|
33
|
+
|
34
|
+
*Gregory Igelmund*
|
35
|
+
|
36
|
+
* Move frequently asked questions to other pages, add History page.
|
37
|
+
|
38
|
+
*Joel Hawksley*
|
39
|
+
|
40
|
+
* Fix typo.
|
41
|
+
|
42
|
+
*James Hart*
|
43
|
+
|
44
|
+
* Add `require "method_source"` if it options.show_previews_source is enabled.
|
45
|
+
|
46
|
+
*Yoshiyuki Hirano*
|
47
|
+
|
48
|
+
* Move show_previews_source definition to Previewable.
|
49
|
+
|
50
|
+
*Yoshiyuki Hirano*
|
51
|
+
|
52
|
+
* Clear cache in MethodSource to apply the change odf preview code without app server restart.
|
53
|
+
|
54
|
+
*Yoshiyuki Hirano*
|
55
|
+
|
10
56
|
## 2.43.1
|
11
57
|
|
12
58
|
* Remove unnecessary call to `ruby2_keywords` for polymorphic slot getters.
|
data/lib/view_component/base.rb
CHANGED
@@ -29,7 +29,7 @@ module ViewComponent
|
|
29
29
|
class_attribute :content_areas
|
30
30
|
self.content_areas = [] # class_attribute:default doesn't work until Rails 5.2
|
31
31
|
|
32
|
-
attr_accessor :
|
32
|
+
attr_accessor :__vc_original_view_context
|
33
33
|
|
34
34
|
# EXPERIMENTAL: This API is experimental and may be removed at any time.
|
35
35
|
# Hook for allowing components to do work as part of the compilation process.
|
@@ -52,7 +52,7 @@ module ViewComponent
|
|
52
52
|
self.class.compile(raise_errors: true)
|
53
53
|
|
54
54
|
@view_context = view_context
|
55
|
-
self.
|
55
|
+
self.__vc_original_view_context ||= view_context
|
56
56
|
|
57
57
|
@lookup_context ||= view_context.lookup_context
|
58
58
|
|
@@ -137,10 +137,10 @@ module ViewComponent
|
|
137
137
|
# @private
|
138
138
|
def render(options = {}, args = {}, &block)
|
139
139
|
if options.is_a? ViewComponent::Base
|
140
|
-
options.
|
140
|
+
options.__vc_original_view_context = __vc_original_view_context
|
141
141
|
super
|
142
142
|
else
|
143
|
-
|
143
|
+
__vc_original_view_context.render(options, args, &block)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -186,7 +186,7 @@ module ViewComponent
|
|
186
186
|
#
|
187
187
|
# This allows ivars to remain persisted when using the same helper via
|
188
188
|
# `helpers` across multiple components and partials.
|
189
|
-
@__vc_helpers ||=
|
189
|
+
@__vc_helpers ||= __vc_original_view_context || controller.view_context
|
190
190
|
end
|
191
191
|
|
192
192
|
# Exposes .virtual_path as an instance method
|
@@ -271,14 +271,6 @@ module ViewComponent
|
|
271
271
|
#
|
272
272
|
mattr_accessor :render_monkey_patch_enabled, instance_writer: false, default: true
|
273
273
|
|
274
|
-
# Enable or disable source code previews in component previews:
|
275
|
-
#
|
276
|
-
# config.view_component.show_previews_source = true
|
277
|
-
#
|
278
|
-
# Defaults to `false`.
|
279
|
-
#
|
280
|
-
mattr_accessor :show_previews_source, instance_writer: false, default: false
|
281
|
-
|
282
274
|
# Always generate a Stimulus controller alongside the component:
|
283
275
|
#
|
284
276
|
# config.view_component.generate_stimulus_controller = true
|
@@ -17,6 +17,7 @@ module ViewComponent
|
|
17
17
|
|
18
18
|
options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
|
19
19
|
options.show_previews = Rails.env.development? || Rails.env.test? if options.show_previews.nil?
|
20
|
+
options.show_previews_source ||= ViewComponent::Base.show_previews_source
|
20
21
|
options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
|
21
22
|
options.preview_route ||= ViewComponent::Base.preview_route
|
22
23
|
options.preview_controller ||= ViewComponent::Base.preview_controller
|
@@ -32,6 +33,14 @@ module ViewComponent
|
|
32
33
|
)
|
33
34
|
options.preview_paths << options.preview_path
|
34
35
|
end
|
36
|
+
|
37
|
+
if options.show_previews_source
|
38
|
+
require "method_source"
|
39
|
+
|
40
|
+
app.config.to_prepare do
|
41
|
+
MethodSource.instance_variable_set(:@lines_for_file, {})
|
42
|
+
end
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
46
|
ActiveSupport.on_load(:view_component) do
|
@@ -15,6 +15,14 @@ module ViewComponent
|
|
15
15
|
#
|
16
16
|
mattr_accessor :show_previews, instance_writer: false
|
17
17
|
|
18
|
+
# Enable or disable source code previews in component previews:
|
19
|
+
#
|
20
|
+
# config.view_component.show_previews_source = true
|
21
|
+
#
|
22
|
+
# Defaults to `false`.
|
23
|
+
#
|
24
|
+
mattr_accessor :show_previews_source, instance_writer: false, default: false
|
25
|
+
|
18
26
|
# Set a custom default layout used for preview index and individual previews:
|
19
27
|
#
|
20
28
|
# config.view_component.default_preview_layout = "component_preview"
|
data/lib/view_component.rb
CHANGED
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.44.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -76,16 +76,16 @@ dependencies:
|
|
76
76
|
name: bundler
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: 1.15.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - "
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: 1.15.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: erb_lint
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,7 +268,7 @@ dependencies:
|
|
268
268
|
- - ">="
|
269
269
|
- !ruby/object:Gem::Version
|
270
270
|
version: '0'
|
271
|
-
description:
|
271
|
+
description:
|
272
272
|
email:
|
273
273
|
- opensource+view_component@github.com
|
274
274
|
executables: []
|
@@ -341,7 +341,7 @@ licenses:
|
|
341
341
|
- MIT
|
342
342
|
metadata:
|
343
343
|
allowed_push_host: https://rubygems.org
|
344
|
-
post_install_message:
|
344
|
+
post_install_message:
|
345
345
|
rdoc_options: []
|
346
346
|
require_paths:
|
347
347
|
- lib
|
@@ -356,8 +356,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
356
|
- !ruby/object:Gem::Version
|
357
357
|
version: '0'
|
358
358
|
requirements: []
|
359
|
-
rubygems_version: 3.2
|
360
|
-
signing_key:
|
359
|
+
rubygems_version: 3.1.2
|
360
|
+
signing_key:
|
361
361
|
specification_version: 4
|
362
362
|
summary: View components for Rails
|
363
363
|
test_files: []
|