view_component 3.21.0 → 3.22.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.
- checksums.yaml +4 -4
- data/app/controllers/concerns/view_component/preview_actions.rb +8 -1
- data/app/helpers/preview_helper.rb +1 -1
- data/app/views/view_components/_preview_source.html.erb +1 -1
- data/docs/CHANGELOG.md +44 -0
- data/lib/view_component/base.rb +4 -0
- data/lib/view_component/configurable.rb +17 -0
- data/lib/view_component/errors.rb +3 -3
- data/lib/view_component/template.rb +2 -2
- data/lib/view_component/version.rb +1 -1
- metadata +22 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6afc3fe994c0954654d58d797e36d274013494e6caec61ef1b5535a4a5a4267
|
4
|
+
data.tar.gz: ae921110a568f5e212b0c2d60cf31bf4ac7628b961a65cde871577f13fddee60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240679c690a13c69669173be5c076271e1a2f0f02dfabfc2bdbfa49c0b03cbd7456e88204c84be3e7b85c703c606270b3c794f47f845d3062c6a9f620fda9da2
|
7
|
+
data.tar.gz: da6b4298a67311608e1641c5ace24e321e6270fb67921f2bb6f70cce9dedb7f53b2ea8006acb193775ce4d4f6a963338f310d754bc95aac6c793a9b52abddf62
|
@@ -14,7 +14,14 @@ module ViewComponent
|
|
14
14
|
|
15
15
|
# Including helpers here ensures that we're loading the
|
16
16
|
# latest version of helpers if code-reloading is enabled
|
17
|
-
|
17
|
+
if include_all_helpers
|
18
|
+
helper :all
|
19
|
+
else
|
20
|
+
# :nocov:
|
21
|
+
# Always provide the #view_source helper
|
22
|
+
helper PreviewHelper
|
23
|
+
# :nocov:
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def index
|
@@ -22,7 +22,7 @@ module PreviewHelper
|
|
22
22
|
serve_static_preview_assets? ? asset_path("prism.min.js", skip_pipeline: true) : "https://cdn.jsdelivr.net/npm/prismjs@1.28.0/prism.min.js"
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def find_template_data_for_preview_source(lookup_context:, template_identifier:)
|
26
26
|
template = lookup_context.find_template(template_identifier)
|
27
27
|
|
28
28
|
if Rails.version.to_f >= 6.1 || template.source.present?
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%= h @preview.preview_source(@example_name) %>
|
8
8
|
</code>
|
9
9
|
<% else %>
|
10
|
-
<% template_data =
|
10
|
+
<% template_data = find_template_data_for_preview_source(lookup_context: @view_renderer.lookup_context, template_identifier: @render_args[:template]) %>
|
11
11
|
<code class="language-<%= template_data[:prism_language_name] %>">
|
12
12
|
<%= h template_data[:source] %>
|
13
13
|
</code>
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,46 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 3.22.0
|
14
|
+
|
15
|
+
* Rewrite `ViewComponents at GitHub` documentation as more general `Best practices`.
|
16
|
+
|
17
|
+
*Phil Schalm*, *Joel Hawksley*
|
18
|
+
|
19
|
+
* Add unused mechanism for inheriting config from parent modules to enable future engine-local configuration.
|
20
|
+
|
21
|
+
*Simon Fish*
|
22
|
+
|
23
|
+
* Improve handling of malformed component edge case when mocking components in tests.
|
24
|
+
|
25
|
+
*Martin Meyerhoff*, *Joel Hawksley*
|
26
|
+
|
27
|
+
* Add Content Harmony & Learn To Be to list of companies using ViewComponent.
|
28
|
+
|
29
|
+
*Kane Jamison*
|
30
|
+
|
31
|
+
* Clarify error message about render-dependent logic.
|
32
|
+
|
33
|
+
Error messages about render-dependent logic were sometimes inaccurate, saying `during initialization` despite also being raised after a component had been initialized but before it was rendered.
|
34
|
+
|
35
|
+
*Joel Hawksley*
|
36
|
+
|
37
|
+
* Remove JS and CSS docs as they proved difficult to maintain and lacked consensus.
|
38
|
+
|
39
|
+
*Joel Hawksley*
|
40
|
+
|
41
|
+
* Do not prefix release tags with `v`, per recommendation from @bkuhlmann.
|
42
|
+
|
43
|
+
*Joel Hawksley*
|
44
|
+
|
45
|
+
* Add ruby 3.4 support to CI.
|
46
|
+
|
47
|
+
*Reegan Viljoen*
|
48
|
+
|
49
|
+
* Add HomeStyler AI to list of companies using ViewComponent.
|
50
|
+
|
51
|
+
*JP Balarini*
|
52
|
+
|
13
53
|
## 3.21.0
|
14
54
|
|
15
55
|
* Updates testing docs to include an example of how to use with RSpec.
|
@@ -218,6 +258,10 @@ nav_order: 5
|
|
218
258
|
|
219
259
|
*Reegan Viljoen*
|
220
260
|
|
261
|
+
* Fix a bug where component previews would crash with "undefined local variable or method `preview_source`."
|
262
|
+
|
263
|
+
*Henning Koch*
|
264
|
+
|
221
265
|
## 3.12.1
|
222
266
|
|
223
267
|
* Ensure content is rendered correctly for forwarded slots.
|
data/lib/view_component/base.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ViewComponent
|
4
|
+
module Configurable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
next if respond_to?(:config) && config.respond_to?(:view_component) && config.respond_to_missing?(:test_controller)
|
9
|
+
|
10
|
+
include ActiveSupport::Configurable
|
11
|
+
|
12
|
+
configure do |config|
|
13
|
+
config.view_component ||= ActiveSupport::InheritableOptions.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -177,7 +177,7 @@ module ViewComponent
|
|
177
177
|
|
178
178
|
class TranslateCalledBeforeRenderError < BaseError
|
179
179
|
MESSAGE =
|
180
|
-
"`#translate` can't be used
|
180
|
+
"`#translate` can't be used before rendering as it depends " \
|
181
181
|
"on the view context that only exists once a ViewComponent is passed to " \
|
182
182
|
"the Rails render pipeline.\n\n" \
|
183
183
|
"It's sometimes possible to fix this issue by moving code dependent on " \
|
@@ -186,7 +186,7 @@ module ViewComponent
|
|
186
186
|
|
187
187
|
class HelpersCalledBeforeRenderError < BaseError
|
188
188
|
MESSAGE =
|
189
|
-
"`#helpers` can't be used
|
189
|
+
"`#helpers` can't be used before rendering as it depends " \
|
190
190
|
"on the view context that only exists once a ViewComponent is passed to " \
|
191
191
|
"the Rails render pipeline.\n\n" \
|
192
192
|
"It's sometimes possible to fix this issue by moving code dependent on " \
|
@@ -195,7 +195,7 @@ module ViewComponent
|
|
195
195
|
|
196
196
|
class ControllerCalledBeforeRenderError < BaseError
|
197
197
|
MESSAGE =
|
198
|
-
"`#controller` can't be used
|
198
|
+
"`#controller` can't be used before rendering, as it depends " \
|
199
199
|
"on the view context that only exists once a ViewComponent is passed to " \
|
200
200
|
"the Rails render pipeline.\n\n" \
|
201
201
|
"It's sometimes possible to fix this issue by moving code dependent on " \
|
@@ -63,8 +63,8 @@ module ViewComponent
|
|
63
63
|
return safe_method_name unless inline_call?
|
64
64
|
|
65
65
|
"maybe_escape_html(#{safe_method_name}) " \
|
66
|
-
"{ Kernel.warn(
|
67
|
-
"The output will be automatically escaped, but you may want to investigate
|
66
|
+
"{ Kernel.warn(\"WARNING: The #{@component} component rendered HTML-unsafe output. " \
|
67
|
+
"The output will be automatically escaped, but you may want to investigate.\") } "
|
68
68
|
end
|
69
69
|
|
70
70
|
def requires_compiled_superclass?
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -48,16 +47,16 @@ dependencies:
|
|
48
47
|
name: concurrent-ruby
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
|
-
- -
|
50
|
+
- - '='
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
52
|
+
version: 1.3.4
|
54
53
|
type: :runtime
|
55
54
|
prerelease: false
|
56
55
|
version_requirements: !ruby/object:Gem::Requirement
|
57
56
|
requirements:
|
58
|
-
- -
|
57
|
+
- - '='
|
59
58
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
59
|
+
version: 1.3.4
|
61
60
|
- !ruby/object:Gem::Dependency
|
62
61
|
name: allocation_stats
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -548,8 +547,20 @@ dependencies:
|
|
548
547
|
- - ">="
|
549
548
|
- !ruby/object:Gem::Version
|
550
549
|
version: '0'
|
551
|
-
|
552
|
-
|
550
|
+
- !ruby/object:Gem::Dependency
|
551
|
+
name: propshaft
|
552
|
+
requirement: !ruby/object:Gem::Requirement
|
553
|
+
requirements:
|
554
|
+
- - "~>"
|
555
|
+
- !ruby/object:Gem::Version
|
556
|
+
version: 1.1.0
|
557
|
+
type: :development
|
558
|
+
prerelease: false
|
559
|
+
version_requirements: !ruby/object:Gem::Requirement
|
560
|
+
requirements:
|
561
|
+
- - "~>"
|
562
|
+
- !ruby/object:Gem::Version
|
563
|
+
version: 1.1.0
|
553
564
|
executables: []
|
554
565
|
extensions: []
|
555
566
|
extra_rdoc_files: []
|
@@ -598,6 +609,7 @@ files:
|
|
598
609
|
- lib/view_component/compiler.rb
|
599
610
|
- lib/view_component/component_error.rb
|
600
611
|
- lib/view_component/config.rb
|
612
|
+
- lib/view_component/configurable.rb
|
601
613
|
- lib/view_component/deprecation.rb
|
602
614
|
- lib/view_component/docs_builder_component.html.erb
|
603
615
|
- lib/view_component/docs_builder_component.rb
|
@@ -633,7 +645,6 @@ metadata:
|
|
633
645
|
allowed_push_host: https://rubygems.org
|
634
646
|
source_code_uri: https://github.com/viewcomponent/view_component
|
635
647
|
changelog_uri: https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md
|
636
|
-
post_install_message:
|
637
648
|
rdoc_options: []
|
638
649
|
require_paths:
|
639
650
|
- lib
|
@@ -648,8 +659,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
648
659
|
- !ruby/object:Gem::Version
|
649
660
|
version: '0'
|
650
661
|
requirements: []
|
651
|
-
rubygems_version: 3.
|
652
|
-
signing_key:
|
662
|
+
rubygems_version: 3.6.2
|
653
663
|
specification_version: 4
|
654
664
|
summary: A framework for building reusable, testable & encapsulated view components
|
655
665
|
in Ruby on Rails.
|