view_component 3.12.1 → 3.13.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/docs/CHANGELOG.md +26 -4
- data/lib/view_component/compiler.rb +2 -2
- data/lib/view_component/instrumentation.rb +1 -1
- data/lib/view_component/use_helpers.rb +20 -10
- data/lib/view_component/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7355cbed890e04169fee1c12513cd045bee0e912838c9d368be9317ee801bfcc
|
4
|
+
data.tar.gz: 76b95e2aab1e097356e06c4c6695a12a1fc0cc3344f3657c1bf42bcb587157cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f7b42ee9a138203348eb6a6560e0d67f041c0d66aaf5eb8465ac6f2ef506eab543a5c408f2a879c70228ae6bef029fc3a916f36344a8835bb8e9d29c4bf89b
|
7
|
+
data.tar.gz: cd8d3a36c04d72941503a255f0143d7ea6f5178364e20e1fac834a7e5ac683b0915588b14cda7c9025bc4ac4cba476c184780940606a968b5449167a9428440f
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,28 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 3.13.0
|
14
|
+
|
15
|
+
* Add ruby head and YJIT to CI.
|
16
|
+
|
17
|
+
*Reegan Viljoen*
|
18
|
+
|
19
|
+
* Fixed a bug where inline templates where unable to remove trailing whitespace without throwing an error.
|
20
|
+
|
21
|
+
*Reegan Viljoen*
|
22
|
+
|
23
|
+
* Fixed CI for Rails main.
|
24
|
+
|
25
|
+
*Reegan Viljoen*
|
26
|
+
|
27
|
+
* Add `from:` option to `use_helpers` to allow for more flexible helper inclusion from modules.
|
28
|
+
|
29
|
+
*Reegan Viljoen*
|
30
|
+
|
31
|
+
* Fixed ruby head matcher issue.
|
32
|
+
|
33
|
+
*Reegan Viljoen*
|
34
|
+
|
13
35
|
## 3.12.1
|
14
36
|
|
15
37
|
* Ensure content is rendered correctly for forwarded slots.
|
@@ -24,15 +46,15 @@ nav_order: 5
|
|
24
46
|
|
25
47
|
* Fix templates not being correctly populated when caller location label has a prefix.
|
26
48
|
|
27
|
-
On the upstream version of Ruby, method owners are now included in backtraces as prefixes. This caused the call stack filtering to not work as intended and thus `source_location` to be incorrect for child ViewComponents, consequently not populating templates correctly.
|
49
|
+
On the upstream version of Ruby, method owners are now included in backtraces as prefixes. This caused the call stack filtering to not work as intended and thus `source_location` to be incorrect for child ViewComponents, consequently not populating templates correctly.
|
28
50
|
|
29
51
|
*Allan Pires, Jason Kim*
|
30
52
|
|
31
53
|
* Use component path for generating RSpec files.
|
32
54
|
|
33
|
-
When generating new RSpec files for components, the generator will use the `view_component_path` value in the config to decide where to put the new spec file. For instance, if the `view_component_path` option has been changed to `app/views/components`, the generator will put the spec file in `spec/views/components`. **If the `view_component_path` doesn't start with `app/`, then the generator will fall back to `spec/components/`.**
|
55
|
+
When generating new RSpec files for components, the generator will use the `view_component_path` value in the config to decide where to put the new spec file. For instance, if the `view_component_path` option has been changed to `app/views/components`, the generator will put the spec file in `spec/views/components`. **If the `view_component_path` doesn't start with `app/`, then the generator will fall back to `spec/components/`.**
|
34
56
|
|
35
|
-
This feature is enabled via the `config.view_component.generate.use_component_path_for_rspec_tests` option, defaulting to `false`. The default will change to `true` in ViewComponent v4.
|
57
|
+
This feature is enabled via the `config.view_component.generate.use_component_path_for_rspec_tests` option, defaulting to `false`. The default will change to `true` in ViewComponent v4.
|
36
58
|
|
37
59
|
*William Mathewson*
|
38
60
|
|
@@ -56,7 +78,7 @@ This feature is enabled via the `config.view_component.generate.use_component_pa
|
|
56
78
|
|
57
79
|
* Include ViewComponent::UseHelpers by default.
|
58
80
|
|
59
|
-
|
81
|
+
*Reegan Viljoen*
|
60
82
|
|
61
83
|
* Bump `puma` in Gemfile.lock.
|
62
84
|
|
@@ -247,9 +247,9 @@ module ViewComponent
|
|
247
247
|
|
248
248
|
def compiled_inline_template(template)
|
249
249
|
handler = ActionView::Template.handler_for_extension(template.language)
|
250
|
-
template
|
250
|
+
template = template.source.dup
|
251
251
|
|
252
|
-
compile_template(template
|
252
|
+
compile_template(template, handler)
|
253
253
|
end
|
254
254
|
|
255
255
|
def compiled_template(file_path)
|
@@ -4,17 +4,27 @@ module ViewComponent::UseHelpers
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
class_methods do
|
7
|
-
def use_helpers(*args)
|
8
|
-
args.each
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
def use_helpers(*args, from: nil)
|
8
|
+
args.each { |helper_method| use_helper(helper_method, from: from) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def use_helper(helper_method, from: nil)
|
12
|
+
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
13
|
+
def #{helper_method}(*args, &block)
|
14
|
+
raise HelpersCalledBeforeRenderError if view_context.nil?
|
15
|
+
|
16
|
+
#{define_helper(helper_method: helper_method, source: from)}
|
17
|
+
end
|
18
|
+
RUBY
|
19
|
+
ruby2_keywords(helper_method) if respond_to?(:ruby2_keywords, true)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def define_helper(helper_method:, source:)
|
25
|
+
return "__vc_original_view_context.#{helper_method}(*args, &block)" unless source.present?
|
15
26
|
|
16
|
-
|
17
|
-
end
|
27
|
+
"#{source}.instance_method(:#{helper_method}).bind(self).call(*args, &block)"
|
18
28
|
end
|
19
29
|
end
|
20
30
|
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: 3.
|
4
|
+
version: 3.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -561,7 +561,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
561
561
|
- !ruby/object:Gem::Version
|
562
562
|
version: '0'
|
563
563
|
requirements: []
|
564
|
-
rubygems_version: 3.5.
|
564
|
+
rubygems_version: 3.5.3
|
565
565
|
signing_key:
|
566
566
|
specification_version: 4
|
567
567
|
summary: A framework for building reusable, testable & encapsulated view components
|