view_component 2.27.0 → 2.28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47f112ee86431b25865a4793374e8838a1e80966d91150d4b182b38c598a9631
4
- data.tar.gz: 97673827cb5a971d8c769b9566c87055d28af37fa04b06b6e90c5098b64c9388
3
+ metadata.gz: 0abc25e32e2befb60487f209469b2d9b96d6f1380a345466bcc816addc9f65d1
4
+ data.tar.gz: a72e8ad8a5cfa1bbfd0bbbaa5510e14abd4818657b356681930537d8d5efa95e
5
5
  SHA512:
6
- metadata.gz: 538a828cd9096fd400cd3b3bc8fa4f63666003221161b22f59a008f62fa5f8d8b311d7152498ff5519004bd960c61d058912fc7241e537d129d9873a4b6c0b63
7
- data.tar.gz: 99de0a2aadb9eb873854b284e0be4f1aa2d20aa8262c5350b3473d536d6e40891d819dff74c73188b1106454a98299511b79e7c406ddebbe05dfdf8ebf69804b
6
+ metadata.gz: 0b3f1cd9a86493fd5fbf68537536435c13b202bcba0d01e8d58f20ba0c158b7cdf1f878c75103d4b6a00f54e89227f7cb6b083bbbab17122e3e7f6b9d7c7f20d
7
+ data.tar.gz: 4a29369a237c75889bce3a0777e5ff82e2bd7d25966ea31004fb293db5a6015aed2abd618340504ee89481d43970a35ff05c3aec2e113ff8b6378ed39415dfec
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 2.28.0
6
+
7
+ * Include SlotableV2 by default in Base. **Note:** It's no longer necessary to include `ViewComponent::SlotableV2` to use Slots.
8
+
9
+ *Joel Hawksley*
10
+
11
+ * Prepend Preview routes instead of appending, accounting for cases where host application has catchall route.
12
+
13
+ *Joel Hawksley*
14
+
15
+ * Fix bug where blocks passed to lambda slots will render incorrectly in certain situations.
16
+
17
+ *Blake Williams*
18
+
5
19
  ## 2.27.0
6
20
 
7
21
  * Allow customization of the controller used in component tests.
@@ -12,6 +12,7 @@ module ViewComponent
12
12
  class Base < ActionView::Base
13
13
  include ActiveSupport::Configurable
14
14
  include ViewComponent::Previewable
15
+ include ViewComponent::SlotableV2
15
16
 
16
17
  ViewContextCalledBeforeRenderError = Class.new(StandardError)
17
18
 
@@ -61,7 +61,7 @@ module ViewComponent
61
61
  "elsif variant.to_sym == :#{variant}\n #{call_method_name(variant)}"
62
62
  end.join("\n")
63
63
 
64
- component_class.class_eval <<-RUBY
64
+ component_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
65
65
  def render_template_for(variant = nil)
66
66
  if variant.nil?
67
67
  call
@@ -90,7 +90,7 @@ module ViewComponent
90
90
  options = app.config.view_component
91
91
 
92
92
  if options.show_previews
93
- app.routes.append do
93
+ app.routes.prepend do
94
94
  preview_controller = options.preview_controller.sub(/Controller$/, "").underscore
95
95
 
96
96
  get options.preview_route, to: "#{preview_controller}#index", as: :preview_view_components, internal: true
@@ -49,14 +49,14 @@ module ViewComponent
49
49
 
50
50
  # If the slot is a collection, define an accesor that defaults to an empty array
51
51
  if collection
52
- class_eval <<-RUBY
52
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
53
53
  def #{accessor_name}
54
54
  content unless content_evaluated? # ensure content is loaded so slots will be defined
55
55
  #{instance_variable_name} ||= []
56
56
  end
57
57
  RUBY
58
58
  else
59
- class_eval <<-RUBY
59
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
60
60
  def #{accessor_name}
61
61
  content unless content_evaluated? # ensure content is loaded so slots will be defined
62
62
  #{instance_variable_name} if defined?(#{instance_variable_name})
@@ -226,7 +226,11 @@ module ViewComponent
226
226
  # Use `bind(self)` to ensure lambda is executed in the context of the
227
227
  # current component. This is necessary to allow the lambda to access helper
228
228
  # methods like `content_tag` as well as parent component state.
229
- renderable_value = slot_definition[:renderable_function].bind(self).call(*args, **kwargs, &block)
229
+ renderable_value = if block_given?
230
+ slot_definition[:renderable_function].bind(self).call(*args, **kwargs) { view_context.capture(&block) }
231
+ else
232
+ slot_definition[:renderable_function].bind(self).call(*args, **kwargs)
233
+ end
230
234
 
231
235
  # Function calls can return components, so if it's a component handle it specially
232
236
  if renderable_value.respond_to?(:render_in)
@@ -3,9 +3,11 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 27
6
+ MINOR = 28
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
11
11
  end
12
+
13
+ puts ViewComponent::VERSION::STRING if __FILE__ == $PROGRAM_NAME
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.27.0
4
+ version: 2.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport