view_component 4.1.1 → 4.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7468565c85b97035ae072333ef8c3851467920aa5ddda57078929106ca32c6ae
4
- data.tar.gz: d9cb57ffb7b7de0236774e0836853ca6c33b717ffce1cc1dd20264784829dc2b
3
+ metadata.gz: 79d1337f1589a6e9ec7617c7d07917825c4f90b2e6093e6e925ef9fad3e06937
4
+ data.tar.gz: aaa0ddcd3a30c628409a4001efdd99c702ff5b97ff7873a3f3e092e05b54c3f6
5
5
  SHA512:
6
- metadata.gz: 1c714baf334d711d94be596712484baf758fb9e03411c6adb1f9e476230e048a3ebe066ef6eeffd079eabaee1240caf68f133c5fb35f82256cff825999ba3852
7
- data.tar.gz: cf63306f08750f07b6d966c21cae7b169d995372dbf249312752ea6b699e5b118ce16f699b03e2c231dac10ea740b0cc9f1ca8aa9185a4247741c1558bfe12a2
6
+ metadata.gz: 98381938a50a979a6ee135dff98c4e3b13a4a1b5ac8ee2f19c7e5f9b1bdc04470b355c55696d2724c733fab29a9379fe59c0a8e4273374e9db5210202be2dc06
7
+ data.tar.gz: 0b5276ff41b7b7ff493f935c75e8c3e8cc604decc42a950c97f1da3becccfba3446b40178c35b9b54578a47f3718bfa53ba2c6e91ec7b929a6adc7f26f41f782
data/docs/CHANGELOG.md CHANGED
@@ -10,11 +10,65 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
- ## 4.1.1
13
+ ## 4.2.0
14
+
15
+ * Fix translation scope resolution in deeply nested component blocks (3+ levels). Translations called inside deeply nested slot blocks using `renders_many`/`renders_one` were incorrectly resolving to an intermediate component's scope instead of the partial's scope where the block was defined. The fix captures the virtual path at block definition time and restores it during block execution, ensuring translations always resolve relative to where the block was created regardless of nesting depth.
16
+
17
+ *Nathaniel Watts*
18
+
19
+ * Allow `render_inline` with Nokogiri::HTML5 to parse more arbitrary content including bare table content otherwise illegal fragments like `<td>`.
20
+
21
+ *Jonathan Rochkind*
22
+
23
+ * Remove known issue from docs as ActiveScaffold is [now compatible](https://github.com/activescaffold/active_scaffold/pull/743) with ViewComponent.
24
+
25
+ *David Löwenfels*
14
26
 
15
- * Add Consultport to list of companies using ViewComponent.
27
+ * Add test to document the current behavior for resolving relative translation keys within partial blocks. When rendering a partial, relative translation keys are resolved relative to the partial's own path rather than the caller’s path. This test ensures that this behavior remains consistent.
28
+
29
+ *Oussama Hilal*
30
+
31
+ * Allow I18n calls in `render?`.
32
+
33
+ *23tux*
34
+
35
+ * ViewComponent now works without `rails` and `railties` gems loaded, enabling compatibility with Bridgetown 2.0.
36
+
37
+ *Tom Lord*
16
38
 
17
- *Sebastian Nepote*
39
+ * Capture partial block in the component's context, allowing access to the component instance inside the block.
40
+
41
+ *23tux*
42
+
43
+ * Add `after_compile` class method hook to enable extensions to run logic after component compilation.
44
+
45
+ *Jose Solás*
46
+
47
+ * Fix outdated reference to preview layout configuration in docs.
48
+
49
+ *Lucas Geron*
50
+
51
+ * Allow ruby-head CI job to fail without failing workflow.
52
+
53
+ *Hakan Ensari*
54
+
55
+ * Fix bug where error line numbers were incorrect in Rails 8.1.
56
+
57
+ *Joel Hawksley*
58
+
59
+ * Remove `< 8.2` upper bound for `activesupport` and `actionview` dependencies.
60
+
61
+ *Hans Lemuet*
62
+
63
+ * Test compatibility with Herb/ReActionView.
64
+
65
+ *Joel Hawksley*
66
+
67
+ * Remove Who Uses ViewComponent section from docs.
68
+
69
+ *Joel Hawksley*
70
+
71
+ ## 4.1.1
18
72
 
19
73
  * Resolve deprecation warning for `ActiveSupport::Configurable`.
20
74
 
@@ -24,20 +78,12 @@ nav_order: 6
24
78
 
25
79
  *Hans Lemuet*
26
80
 
27
- * Added Reinvented Hospitality to the list of companies using ViewComponent.
28
-
29
- *Torgil Zechel*
30
-
31
81
  ## 4.1.0
32
82
 
33
83
  * Add Rails 8.1 support.
34
84
 
35
85
  *Hans Lemuet*
36
86
 
37
- * Add Carwow to list of companies using ViewComponent.
38
-
39
- *Tom Lord*
40
-
41
87
  * Declare `actionview` as a `view_component` gem dependency.
42
88
 
43
89
  *Michal Cichra*
@@ -520,10 +566,6 @@ This release makes the following breaking changes:
520
566
 
521
567
  *Martin Meyerhoff*, *Joel Hawksley*
522
568
 
523
- * Add Content Harmony & Learn To Be to list of companies using ViewComponent.
524
-
525
- *Kane Jamison*
526
-
527
569
  * Clarify error message about render-dependent logic.
528
570
 
529
571
  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.
@@ -542,10 +584,6 @@ This release makes the following breaking changes:
542
584
 
543
585
  *Reegan Viljoen*
544
586
 
545
- * Add HomeStyler AI to list of companies using ViewComponent.
546
-
547
- *JP Balarini*
548
-
549
587
  ## 3.21.0
550
588
 
551
589
  * Updates testing docs to include an example of how to use with RSpec.
@@ -556,10 +594,6 @@ This release makes the following breaking changes:
556
594
 
557
595
  *KAWAKAMI Moeki*
558
596
 
559
- * Add FreeATS to list of companies using ViewComponent.
560
-
561
- *Ilia Liamshin*
562
-
563
597
  * Ensure HTML output safety wrapper is used for all inline templates.
564
598
 
565
599
  *Joel Hawksley*
@@ -610,10 +644,6 @@ This release makes the following breaking changes:
610
644
 
611
645
  *Blake Williams*
612
646
 
613
- * Add [Niva]([niva.co](https://www.niva.co/)) to companies who use `ViewComponent`.
614
-
615
- *Daniel Vu Dao*
616
-
617
647
  * Fix `preview_paths` in docs.
618
648
 
619
649
  *Javier Aranda*
@@ -678,10 +708,6 @@ This release makes the following breaking changes:
678
708
 
679
709
  *Joel Hawksley*
680
710
 
681
- * Add Kicksite to list of companies using ViewComponent.
682
-
683
- *Adil Lari*
684
-
685
711
  * Allow overridden slot methods to use `super`.
686
712
 
687
713
  *Andrew Schwartz*
@@ -921,10 +947,6 @@ This release makes the following breaking changes:
921
947
 
922
948
  *Simon Fish*
923
949
 
924
- * Add Simundia to list of companies using ViewComponent.
925
-
926
- *Alexandre Ignjatovic*
927
-
928
950
  * Reduce UnboundMethod objects by memoizing initialize_parameters.
929
951
 
930
952
  *Rainer Borene*
@@ -975,10 +997,6 @@ This release makes the following breaking changes:
975
997
 
976
998
  *milk1000cc*
977
999
 
978
- * Add PeopleForce to list of companies using ViewComponent.
979
-
980
- *Volodymyr Khandiuk*
981
-
982
1000
  ## 3.5.0
983
1001
 
984
1002
  * Add Skroutz to users list.
@@ -1053,14 +1071,6 @@ This release makes the following breaking changes:
1053
1071
 
1054
1072
  *Joel Hawksley*
1055
1073
 
1056
- * Add Ophelos to list of companies using ViewComponent.
1057
-
1058
- *Graham Rogers*
1059
-
1060
- * Add FlightLogger to list of companies using ViewComponent.
1061
-
1062
- *Joseph Carpenter*
1063
-
1064
1074
  * Fix coverage reports overwriting each other when running locally.
1065
1075
 
1066
1076
  *Jonathan del Strother*
@@ -1300,14 +1310,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1300
1310
 
1301
1311
  *Graham Rogers*
1302
1312
 
1303
- * Add Krystal to list of companies using ViewComponent.
1304
-
1305
- *Matt Bearman*
1306
-
1307
- * Add Mon Ami to list of companies using ViewComponent.
1308
-
1309
- *Ethan Lee-Tyson*
1310
-
1311
1313
  ## 3.0.0.rc1
1312
1314
 
1313
1315
  1,000+ days and 100+ releases later, the 200+ contributors to ViewComponent are proud to ship v3.0.0!
@@ -1456,10 +1458,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1456
1458
 
1457
1459
  *Hans Lemuet*
1458
1460
 
1459
- * Add Startup Jobs to list of companies using ViewComponent.
1460
-
1461
- *Marc Köhlbrugge*
1462
-
1463
1461
  * Run PVC's accessibility tests in a single process to avoid resource contention in CI.
1464
1462
 
1465
1463
  *Cameron Dutro*
@@ -1500,10 +1498,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1500
1498
 
1501
1499
  ## 2.74.0
1502
1500
 
1503
- * Add Avo to list of companies using ViewComponent.
1504
-
1505
- *Adrian Marin*
1506
-
1507
1501
  * Promote experimental `_output_postamble` method to public API as `output_postamble`.
1508
1502
 
1509
1503
  *Joel Hawksley*
@@ -1530,10 +1524,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1530
1524
 
1531
1525
  *Erinna Chen*
1532
1526
 
1533
- * Add PrintReleaf to list of companies using ViewComponent.
1534
-
1535
- *Ry Kulp*
1536
-
1537
1527
  * Simplify CI configuration to a single build per Ruby/Rails version.
1538
1528
 
1539
1529
  *Joel Hawksley*
@@ -1542,10 +1532,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1542
1532
 
1543
1533
  *Ruben Smit*
1544
1534
 
1545
- * Add Yobbers to list of companies using ViewComponent.
1546
-
1547
- *Anton Prins*
1548
-
1549
1535
  ## 2.72.0
1550
1536
 
1551
1537
  * Deprecate support for Ruby < 2.7 for removal in v3.0.0.
@@ -1560,10 +1546,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1560
1546
 
1561
1547
  *Joel Hawksley.
1562
1548
 
1563
- * Add Aluuno to list of companies using ViewComponent.
1564
-
1565
- *Daniel Naves de Carvalho*
1566
-
1567
1549
  * Add `source_code_uri` to gemspec.
1568
1550
 
1569
1551
  *Yoshiyuki Hirano*
@@ -1598,22 +1580,10 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1598
1580
 
1599
1581
  *Joel Hawksley*
1600
1582
 
1601
- * Add Arrows to list of companies using ViewComponent.
1602
-
1603
- *Matt Swanson*
1604
-
1605
- * Add WIP to list of companies using ViewComponent.
1606
-
1607
- *Marc Köhlbrugge*
1608
-
1609
1583
  * Update slots documentation to include how to reference slots.
1610
1584
 
1611
1585
  *Brittany Ellich*
1612
1586
 
1613
- * Add Clio to list of companies using ViewComponent.
1614
-
1615
- *Mike Buckley*
1616
-
1617
1587
  ## 2.69.0
1618
1588
 
1619
1589
  * Add missing `require` to fix `pvc` build.
@@ -1731,10 +1701,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1731
1701
 
1732
1702
  *Vikram Dighe*
1733
1703
 
1734
- * Add HappyCo to list of companies using ViewComponent.
1735
-
1736
- *Josh Clayton*
1737
-
1738
1704
  * Add predicate method support to polymorphic slots.
1739
1705
 
1740
1706
  *Graham Rogers*
@@ -1845,10 +1811,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1845
1811
 
1846
1812
  *Thomas Hutterer*
1847
1813
 
1848
- * Add FreeAgent to list of companies using ViewComponent.
1849
-
1850
- *Simon Fish*
1851
-
1852
1814
  * Include polymorphic slots in `ViewComponent::Base` by default.
1853
1815
 
1854
1816
  *Cameron Dutro*
@@ -1904,18 +1866,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1904
1866
 
1905
1867
  *Joel Hawksley*
1906
1868
 
1907
- * Add G2 to list of companies that use ViewComponent.
1908
-
1909
- *Jack Shuff*
1910
-
1911
- * Add Within3 to list of companies that use ViewComponent.
1912
-
1913
- *Drew Bragg*
1914
-
1915
- * Add Mission Met to list of companies that use ViewComponent.
1916
-
1917
- *Nick Smith*
1918
-
1919
1869
  * Fix `#with_request_url` test helper not parsing nested query parameters into nested hashes.
1920
1870
 
1921
1871
  *Richard Marbach*
@@ -1955,10 +1905,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1955
1905
 
1956
1906
  *Blake Williams*
1957
1907
 
1958
- * Add QuickNode to list of companies that use ViewComponent.
1959
-
1960
- *Luc Castera*
1961
-
1962
1908
  * Include the `Translatable` module by default.
1963
1909
 
1964
1910
  *Elia Schito*
@@ -1989,10 +1935,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
1989
1935
 
1990
1936
  *Jason Swett*
1991
1937
 
1992
- * Add Bearer to list of companies that use ViewComponent.
1993
-
1994
- *Yaroslav Shmarov*
1995
-
1996
1938
  * Add articles to resources page.
1997
1939
 
1998
1940
  *Joel Hawksley*
@@ -2022,10 +1964,6 @@ Run into an issue with this release? [Let us know](https://github.com/ViewCompon
2022
1964
 
2023
1965
  *Hans Lemuet*
2024
1966
 
2025
- * Alphabetize companies using ViewComponent and add Brightline to the list.
2026
-
2027
- *Jack Schuss*
2028
-
2029
1967
  * Add CMYK value for ViewComponent Red color on logo page.
2030
1968
 
2031
1969
  *Dylan Smith*
@@ -46,7 +46,7 @@ module ViewComponent
46
46
  end
47
47
 
48
48
  include ActionView::Helpers
49
- include Rails.application.routes.url_helpers if defined?(Rails) && Rails.application
49
+ include Rails.application.routes.url_helpers if defined?(Rails.application.routes)
50
50
  include ERB::Escape
51
51
  include ActiveSupport::CoreExt::ERBUtil
52
52
 
@@ -131,6 +131,7 @@ module ViewComponent
131
131
 
132
132
  @__vc_content_evaluated = false
133
133
  @__vc_render_in_block = block
134
+ @view_context.instance_variable_set(:@virtual_path, virtual_path)
134
135
 
135
136
  before_render
136
137
 
@@ -138,8 +139,6 @@ module ViewComponent
138
139
  value = nil
139
140
 
140
141
  @output_buffer.with_buffer do
141
- @view_context.instance_variable_set(:@virtual_path, virtual_path)
142
-
143
142
  rendered_template =
144
143
  around_render do
145
144
  render_template_for(@__vc_requested_details).to_s
@@ -260,6 +259,9 @@ module ViewComponent
260
259
  @view_context.render(options, args, &block)
261
260
  elsif block
262
261
  __vc_original_view_context.render(options, args) do
262
+ # capture the block output in the view context of the component
263
+ output = capture(&block)
264
+
263
265
  # Partials are rendered to their own buffer and do not append to the
264
266
  # original @output_buffer we retain a reference to in #render_in. This
265
267
  # is a problem since the block passed to us here in the #render method
@@ -267,7 +269,7 @@ module ViewComponent
267
269
  # appends to the original @output_buffer. To avoid this, we evaluate the
268
270
  # block in the view context instead, which will append to the output buffer
269
271
  # created for the partial.
270
- __vc_original_view_context.instance_exec(&block)
272
+ __vc_original_view_context.capture { output }
271
273
  end
272
274
  else
273
275
  __vc_original_view_context.render(options, args)
@@ -301,7 +303,7 @@ module ViewComponent
301
303
  @__vc_helpers ||= __vc_original_view_context || controller.view_context
302
304
  end
303
305
 
304
- if ::Rails.env.development? || ::Rails.env.test?
306
+ if defined?(Rails.env) && (::Rails.env.development? || ::Rails.env.test?)
305
307
  # @private
306
308
  def method_missing(method_name, *args) # rubocop:disable Style/MissingRespondToMissing
307
309
  super
@@ -330,7 +332,7 @@ module ViewComponent
330
332
  []
331
333
  end
332
334
 
333
- if Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR == 1
335
+ if defined?(Rails::VERSION) && Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR == 1
334
336
  # Rails expects us to define `format` on all renderables,
335
337
  # but we do not know the `format` of a ViewComponent until runtime.
336
338
  def format
@@ -361,7 +363,7 @@ module ViewComponent
361
363
 
362
364
  @__vc_content =
363
365
  if __vc_render_in_block_provided?
364
- with_original_virtual_path do
366
+ with_captured_virtual_path(@old_virtual_path) do
365
367
  view_context.capture(self, &@__vc_render_in_block)
366
368
  end
367
369
  elsif __vc_content_set_by_with_content_defined?
@@ -377,11 +379,14 @@ module ViewComponent
377
379
  end
378
380
 
379
381
  # @private
380
- def with_original_virtual_path
381
- @view_context.instance_variable_set(:@virtual_path, @old_virtual_path)
382
+ # Temporarily sets the virtual path to the captured value, then restores it.
383
+ # This ensures translations and other path-dependent code execute with the correct scope.
384
+ def with_captured_virtual_path(captured_path)
385
+ old_virtual_path = @view_context.instance_variable_get(:@virtual_path)
386
+ @view_context.instance_variable_set(:@virtual_path, captured_path)
382
387
  yield
383
388
  ensure
384
- @view_context.instance_variable_set(:@virtual_path, virtual_path)
389
+ @view_context.instance_variable_set(:@virtual_path, old_virtual_path)
385
390
  end
386
391
 
387
392
  private
@@ -610,6 +615,16 @@ module ViewComponent
610
615
  __vc_compiler.compiled?
611
616
  end
612
617
 
618
+ # Hook called by the compiler after a component is compiled.
619
+ #
620
+ # Extensions can override this class method to run logic after
621
+ # compilation (e.g., generate helpers, register metadata, etc.).
622
+ #
623
+ # By default, this is a no-op.
624
+ def after_compile
625
+ # no-op by default
626
+ end
627
+
613
628
  # @private
614
629
  def __vc_ensure_compiled
615
630
  __vc_compile unless __vc_compiled?
@@ -20,7 +20,7 @@ module ViewComponent
20
20
  components.each(&block)
21
21
  end
22
22
 
23
- if Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR == 1
23
+ if defined?(Rails::VERSION) && Rails::VERSION::MAJOR == 7 && Rails::VERSION::MINOR == 1
24
24
  # Rails expects us to define `format` on all renderables,
25
25
  # but we do not know the `format` of a ViewComponent until runtime.
26
26
  def format
@@ -52,6 +52,8 @@ module ViewComponent
52
52
  @component.__vc_build_i18n_backend
53
53
 
54
54
  CompileCache.register(@component)
55
+
56
+ @component.after_compile
55
57
  end
56
58
  end
57
59
 
@@ -163,7 +163,7 @@ module ViewComponent
163
163
  options = ActiveSupport::OrderedOptions.new
164
164
  options.controller = "ViewComponentsController"
165
165
  options.route = "/rails/view_components"
166
- options.enabled = Rails.env.development? || Rails.env.test?
166
+ options.enabled = defined?(Rails.env) && (Rails.env.development? || Rails.env.test?)
167
167
  options.default_layout = nil
168
168
  options.paths = default_preview_paths
169
169
  options
@@ -6,7 +6,7 @@ module ViewComponent
6
6
  class Slot
7
7
  include ViewComponent::WithContentHelper
8
8
 
9
- attr_writer :__vc_component_instance, :__vc_content_block, :__vc_content
9
+ attr_writer :__vc_component_instance, :__vc_content_block, :__vc_content, :__vc_content_block_virtual_path
10
10
 
11
11
  def initialize(parent)
12
12
  @parent = parent
@@ -58,7 +58,7 @@ module ViewComponent
58
58
  if defined?(@__vc_content_block)
59
59
  # render_in is faster than `parent.render`
60
60
  @__vc_component_instance.render_in(view_context) do |*args|
61
- @parent.with_original_virtual_path do
61
+ @parent.with_captured_virtual_path(@__vc_content_block_virtual_path) do
62
62
  @__vc_content_block.call(*args)
63
63
  end
64
64
  end
@@ -68,7 +68,7 @@ module ViewComponent
68
68
  elsif defined?(@__vc_content)
69
69
  @__vc_content
70
70
  elsif defined?(@__vc_content_block)
71
- @parent.with_original_virtual_path do
71
+ @parent.with_captured_virtual_path(@__vc_content_block_virtual_path) do
72
72
  view_context.capture(&@__vc_content_block)
73
73
  end
74
74
  elsif defined?(@__vc_content_set_by_with_content)
@@ -390,7 +390,12 @@ module ViewComponent
390
390
  # 2. Since we have to pass block content to components when calling
391
391
  # `render`, evaluating the block here would require us to call
392
392
  # `view_context.capture` twice, which is slower
393
- slot.__vc_content_block = block if block
393
+ if block
394
+ slot.__vc_content_block = block
395
+ # Capture the virtual path at the time the block is defined, so that
396
+ # translations resolve relative to where the block was created, not where it's rendered
397
+ slot.__vc_content_block_virtual_path = view_context.instance_variable_get(:@virtual_path)
398
+ end
394
399
 
395
400
  # If class
396
401
  if slot_definition[:renderable]
@@ -408,7 +413,9 @@ module ViewComponent
408
413
  renderable_value =
409
414
  if block
410
415
  renderable_function.call(*args, **kwargs) do |*rargs|
411
- view_context.capture(*rargs, &block)
416
+ with_captured_virtual_path(@old_virtual_path) do
417
+ view_context.capture(*rargs, &block)
418
+ end
412
419
  end
413
420
  else
414
421
  renderable_function.call(*args, **kwargs)
@@ -21,11 +21,20 @@ module ViewComponent
21
21
 
22
22
  class File < Template
23
23
  def initialize(component:, details:, path:)
24
+ # Rails 8.1 added a newline to the compiled ERB output in
25
+ # https://github.com/rails/rails/pull/53731
26
+ lineno =
27
+ if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR > 0 && details.handler == :erb
28
+ - 1
29
+ else
30
+ 0
31
+ end
32
+
24
33
  super(
25
34
  component: component,
26
35
  details: details,
27
36
  path: path,
28
- lineno: 0
37
+ lineno: lineno
29
38
  )
30
39
  end
31
40
 
@@ -45,11 +54,20 @@ module ViewComponent
45
54
  def initialize(component:, inline_template:)
46
55
  details = ActionView::TemplateDetails.new(nil, inline_template.language.to_sym, nil, nil)
47
56
 
57
+ # Rails 8.1 added a newline to the compiled ERB output in
58
+ # https://github.com/rails/rails/pull/53731
59
+ lineno =
60
+ if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR > 0 && details.handler == :erb
61
+ inline_template.lineno - 1
62
+ else
63
+ inline_template.lineno
64
+ end
65
+
48
66
  super(
49
67
  component: component,
50
68
  details: details,
51
69
  path: inline_template.path,
52
- lineno: inline_template.lineno,
70
+ lineno: lineno,
53
71
  )
54
72
 
55
73
  @source = inline_template.source.dup
@@ -40,7 +40,7 @@ module ViewComponent
40
40
  @page = nil
41
41
  @rendered_content = vc_test_view_context.render(component, args, &block)
42
42
 
43
- fragment = Nokogiri::HTML5.fragment(@rendered_content)
43
+ fragment = Nokogiri::HTML5.fragment(@rendered_content, context: "template")
44
44
  @vc_test_view_context = nil
45
45
  fragment
46
46
  end
@@ -3,8 +3,8 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 4
6
- MINOR = 1
7
- PATCH = 1
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
@@ -17,7 +17,7 @@ module ViewComponent
17
17
  autoload :Preview
18
18
  autoload :Translatable
19
19
 
20
- if Rails.env.test?
20
+ if defined?(Rails.env) && Rails.env.test?
21
21
  autoload :TestHelpers
22
22
  autoload :SystemSpecHelpers
23
23
  autoload :SystemTestHelpers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
@@ -16,9 +16,6 @@ dependencies:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: 7.1.0
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '8.2'
22
19
  type: :runtime
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,9 +23,6 @@ dependencies:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
25
  version: 7.1.0
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '8.2'
32
26
  - !ruby/object:Gem::Dependency
33
27
  name: actionview
34
28
  requirement: !ruby/object:Gem::Requirement
@@ -36,9 +30,6 @@ dependencies:
36
30
  - - ">="
37
31
  - !ruby/object:Gem::Version
38
32
  version: 7.1.0
39
- - - "<"
40
- - !ruby/object:Gem::Version
41
- version: '8.2'
42
33
  type: :runtime
43
34
  prerelease: false
44
35
  version_requirements: !ruby/object:Gem::Requirement
@@ -46,9 +37,6 @@ dependencies:
46
37
  - - ">="
47
38
  - !ruby/object:Gem::Version
48
39
  version: 7.1.0
49
- - - "<"
50
- - !ruby/object:Gem::Version
51
- version: '8.2'
52
40
  - !ruby/object:Gem::Dependency
53
41
  name: concurrent-ruby
54
42
  requirement: !ruby/object:Gem::Requirement