Skip to content

Commit

Permalink
Address Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitkkr committed Jun 30, 2022
1 parent 1d2157e commit dd6d56a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ is the same as using this in the main layout:
<%= stylesheet_pack_tag 'calendar', 'map', application' %>
```


However, you typically can't do that in the main layout, as the view and partial codes will depend on the route.

Thus, you can distribute the logic of what packs are needed for any route. All the magic of splitting up the code was automatic!
Thus, you can distribute the logic of what packs are needed for any route. All the magic of splitting up the code and CSS was automatic!

**Important:** `append_javascript_pack_tag` can be used anywhere in your application as long as it is executed BEFORE the `javascript_pack_tag`. If you attempt to call `append_javascript_pack_tag` helper after `javascript_pack_tag`, an error will be raised. You should have only a single `javascript_pack_tag` invocation in your page load.

Expand Down
21 changes: 21 additions & 0 deletions test/helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ def test_stylesheet_pack_tag_multiple_invocations_are_allowed
assert_equal \
hello_stimulus_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
stimulus_style

assert_nothing_raised do
stylesheet_pack_tag(:application)
stylesheet_pack_tag(:hello_stimulus)
end
end

def test_stylesheet_pack_with_append
Expand All @@ -224,6 +229,22 @@ def test_stylesheet_pack_with_duplicate_append
end

def test_multiple_stylesheet_pack_with_different_media_attr
app_style = stylesheet_pack_tag(:application)
app_style_with_media = stylesheet_pack_tag(:application, media: "print")
hello_stimulus_style_with_media = stylesheet_pack_tag(:hello_stimulus, media: "all")

assert_equal \
application_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
app_style

assert_equal \
application_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk, media: "print") }.join("\n"),
app_style_with_media

assert_equal \
hello_stimulus_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk, media: "all") }.join("\n"),
hello_stimulus_style_with_media

assert_nothing_raised do
stylesheet_pack_tag(:application)
stylesheet_pack_tag(:application, media: "print")
Expand Down

0 comments on commit dd6d56a

Please sign in to comment.