Skip to content

Commit db1157c

Browse files
Merge branch 'main' into rv_add_component_caching
2 parents a75cf58 + 21b94a7 commit db1157c

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nav_order: 5
1010

1111
## main
1212

13+
* Fix bug where implicit locales in component filenames threw a `NameError`.
14+
15+
*Chloe Fons*
16+
1317
* Register ViewComponent tests directory for `rails stats`.
1418

1519
*Javier Aranda*

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ ViewComponent is built by over a hundred members of the community, including:
228228
<img src="https://avatars.githubusercontent.com/allan-pires?s=64" alt="allan-pires" width="32" />
229229
<img src="https://avatars.githubusercontent.com/jasonkim?s=64" alt="jasonkim" width="32" />
230230
<img src="https://avatars.githubusercontent.com/tkowalewski" alt="tkowalewski" width="32" />
231+
<img src="https://avatars.githubusercontent.com/chloe-meister" alt="chloe-meister" width="32" />
231232
<img src="https://avatars.githubusercontent.com/zaratan" alt="zaratan" width="32" />
232233

233234
## Who uses ViewComponent?

lib/view_component/compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def gather_templates
192192
path: path,
193193
lineno: 0,
194194
extension: path.split(".").last,
195-
this_format: this_format,
195+
this_format: this_format.to_s.split(".").last&.to_sym, # strip locale from this_format, see #2113
196196
variant: variant
197197
)
198198

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>salut,monde!</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
class LocalisedComponent < ViewComponent::Base
4+
end

test/sandbox/test/rendering_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,4 +1232,10 @@ def test_cache_component
12321232
refute_selector(".cache-component__cache-key", text: component.cache_key)
12331233
refute_selector(".cache-component__cache-message", text: "foo bar")
12341234
end
1235+
1236+
def test_localised_component
1237+
render_inline(LocalisedComponent.new)
1238+
1239+
assert_selector("div", text: "salut,monde!")
1240+
end
12351241
end

0 commit comments

Comments
 (0)