Skip to content

Commit 805ec5b

Browse files
authored
Add stylesheet link tag in application layout (#15)
* Add stylesheet link tag in application layout * Check if turbo is installed
1 parent e9b5f39 commit 805ec5b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/install/install.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313
say "Remove app/assets/stylesheets/application.css so build output can take over"
1414
remove_file "app/assets/stylesheets/application.css"
1515

16+
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
17+
say "Add stylesheet link tag in application layout"
18+
insert_into_file(
19+
app_layout_path.to_s,
20+
defined?(Turbo) ?
21+
%(\n <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>) :
22+
%(\n <%= stylesheet_link_tag "application" %>),
23+
before: /\s*<\/head>/
24+
)
25+
else
26+
say "Default application.html.erb is missing!", :red
27+
if defined?(Turbo)
28+
say %( Add <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
29+
else
30+
say %( Add <%= stylesheet_link_tag "application" %> within the <head> tag in your custom layout.)
31+
end
32+
end
33+
1634
unless Rails.root.join("package.json").exist?
1735
say "Add default package.json"
1836
copy_file "#{__dir__}/package.json", "package.json"

0 commit comments

Comments
 (0)