Skip to content

Commit e7cdbcd

Browse files
Preserve options with stylesheet_link_tag :all (#177)
Ensure that we don't lose any options passed to `stylesheet_link_tag` when using the `:all` option. Previously the options were being discarded.
1 parent 40ce740 commit e7cdbcd

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/propshaft/helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ def compute_asset_path(path, options = {})
55
end
66

77
# Add an option to call `stylesheet_link_tag` with `:all` to include every css file found on the load path.
8-
def stylesheet_link_tag(*sources)
8+
def stylesheet_link_tag(*sources, **options)
99
if sources.first == :all
10-
super *all_stylesheets_paths
10+
super *all_stylesheets_paths, **options
1111
else
1212
super
1313
end

test/dummy/app/views/layouts/application.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<%= csrf_meta_tags %>
66
<%= csp_meta_tag %>
77

8-
<%= stylesheet_link_tag :all %>
8+
<%= stylesheet_link_tag :all, data: { custom_attribute: true } %>
99
</head>
1010

1111
<body>

test/propshaft_integration_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class PropshaftIntegrationTest < ActionDispatch::IntegrationTest
66

77
assert_response :success
88

9-
assert_select 'link[href="/assets/hello_world-4137140a.css"]'
10-
assert_select 'link[href="/assets/goodbye-b1dc9940.css"]'
9+
assert_select 'link[href="/assets/hello_world-4137140a.css"][data-custom-attribute="true"]'
10+
assert_select 'link[href="/assets/goodbye-b1dc9940.css"][data-custom-attribute="true"]'
1111

1212
assert_select 'script[src="/assets/hello_world-888761f8.js"]'
1313
end

0 commit comments

Comments
 (0)