view_component 3.12.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +32 -4
- data/lib/view_component/compiler.rb +2 -2
- data/lib/view_component/instrumentation.rb +1 -1
- data/lib/view_component/slot.rb +11 -1
- data/lib/view_component/use_helpers.rb +20 -10
- data/lib/view_component/version.rb +1 -1
- 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,34 @@ 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
|
+
|
35
|
+
## 3.12.1
|
36
|
+
|
37
|
+
* Ensure content is rendered correctly for forwarded slots.
|
38
|
+
|
39
|
+
*Cameron Dutro*
|
40
|
+
|
13
41
|
## 3.12.0
|
14
42
|
|
15
43
|
* Remove offline links from resources.
|
@@ -18,15 +46,15 @@ nav_order: 5
|
|
18
46
|
|
19
47
|
* Fix templates not being correctly populated when caller location label has a prefix.
|
20
48
|
|
21
|
-
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.
|
22
50
|
|
23
51
|
*Allan Pires, Jason Kim*
|
24
52
|
|
25
53
|
* Use component path for generating RSpec files.
|
26
54
|
|
27
|
-
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/`.**
|
28
56
|
|
29
|
-
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.
|
30
58
|
|
31
59
|
*William Mathewson*
|
32
60
|
|
@@ -50,7 +78,7 @@ This feature is enabled via the `config.view_component.generate.use_component_pa
|
|
50
78
|
|
51
79
|
* Include ViewComponent::UseHelpers by default.
|
52
80
|
|
53
|
-
|
81
|
+
*Reegan Viljoen*
|
54
82
|
|
55
83
|
* Bump `puma` in Gemfile.lock.
|
56
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)
|
data/lib/view_component/slot.rb
CHANGED
@@ -57,7 +57,17 @@ module ViewComponent
|
|
57
57
|
|
58
58
|
if defined?(@__vc_content_block)
|
59
59
|
# render_in is faster than `parent.render`
|
60
|
-
@__vc_component_instance.render_in(view_context
|
60
|
+
@__vc_component_instance.render_in(view_context) do |*args|
|
61
|
+
return @__vc_content_block.call(*args) if @__vc_content_block&.source_location.nil?
|
62
|
+
|
63
|
+
block_context = @__vc_content_block.binding.receiver
|
64
|
+
|
65
|
+
if block_context.class < ActionView::Base
|
66
|
+
block_context.capture(*args, &@__vc_content_block)
|
67
|
+
else
|
68
|
+
@__vc_content_block.call(*args)
|
69
|
+
end
|
70
|
+
end
|
61
71
|
else
|
62
72
|
@__vc_component_instance.render_in(view_context)
|
63
73
|
end
|
@@ -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
|