view_component 3.12.1 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 875f47469a83b3b70de2e4271cc4af72542d88c6e12c373c8f6912d3c8c6d13e
4
- data.tar.gz: 161671b627c087f227706c10e6ca7f900dcdd3d2ea49232024543bf78a3be14b
3
+ metadata.gz: 7355cbed890e04169fee1c12513cd045bee0e912838c9d368be9317ee801bfcc
4
+ data.tar.gz: 76b95e2aab1e097356e06c4c6695a12a1fc0cc3344f3657c1bf42bcb587157cc
5
5
  SHA512:
6
- metadata.gz: aaa215e2aba616eca2ea0e1bd1e4ab76df2f6f4f34d1f3f225a5802a943b8e6c8e920b3821fda06353e52979345a8d941c2d3d2eaa24b71a6928502846224acc
7
- data.tar.gz: f7da13dfa835866ac685d567f41549857ca40682e6f2beee269bf07b4b9bfaf942af62d03dbcc019cb72ef349ed8c601be24c1598efd0cb38e26397decb4e09a
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
- *Reegan Viljoen*
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.rstrip! if component_class.strip_trailing_whitespace?
250
+ template = template.source.dup
251
251
 
252
- compile_template(template.source, handler)
252
+ compile_template(template, handler)
253
253
  end
254
254
 
255
255
  def compiled_template(file_path)
@@ -16,7 +16,7 @@ module ViewComponent # :nodoc:
16
16
  identifier: self.class.identifier
17
17
  }
18
18
  ) do
19
- super(view_context, &block)
19
+ super
20
20
  end
21
21
  end
22
22
 
@@ -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 do |helper_method|
9
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
10
- def #{helper_method}(*args, &block)
11
- raise HelpersCalledBeforeRenderError if view_context.nil?
12
- __vc_original_view_context.#{helper_method}(*args, &block)
13
- end
14
- RUBY
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
- ruby2_keywords(helper_method) if respond_to?(:ruby2_keywords, true)
17
- end
27
+ "#{source}.instance_method(:#{helper_method}).bind(self).call(*args, &block)"
18
28
  end
19
29
  end
20
30
  end
@@ -3,8 +3,8 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 12
7
- PATCH = 1
6
+ MINOR = 13
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
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.12.1
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-04-17 00:00:00.000000000 Z
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.4
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