Skip to content

Commit 2ad3f4c

Browse files
create the flashes partial when running the install generator instead of the generators
1 parent d1abd37 commit 2ad3f4c

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

lib/generators/tailwindcss/authentication/authentication_generator.rb

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ module Tailwindcss
44
module Generators
55
class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator
66
source_root File.expand_path("templates", __dir__)
7-
8-
def copy_view_files
9-
template "../../scaffold/templates/_flashes.html.erb", "app/views/application/_flashes.html.erb"
10-
end
117
end
128
end
139
end

lib/generators/tailwindcss/scaffold/scaffold_generator.rb

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def copy_view_files
2424
end
2525

2626
template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_name}.html.erb")
27-
template "_flashes.html.erb", "app/views/application/_flashes.html.erb"
2827
end
2928

3029
private

lib/generators/tailwindcss/scaffold/templates/_flashes.html.erb.tt

-7
This file was deleted.

lib/install/_flashes.html.erb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<% if notice.present? %>
2+
<p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-md bg-green-50" id="notice"><%= notice %></p>
3+
<% end %>
4+
5+
<% if alert.present? %>
6+
<p class="inline-block px-3 py-2 mb-5 font-medium text-red-500 rounded-lg bg-red-50" id="alert"><%= alert %></p>
7+
<% end %>

lib/install/tailwindcss.rb

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css"
3939
end
4040

41+
empty_directory "app/views/application"
42+
unless Rails.root.join("app/views/application/_flashes.html.erb").exist?
43+
say "Add default app/views/application/_flashes.html.erb"
44+
copy_file "#{__dir__}/_flashes.html.erb", "app/views/application/_flashes.html.erb"
45+
end
46+
4147
if Rails.root.join("Procfile.dev").exist?
4248
append_to_file "Procfile.dev", "css: bin/rails tailwindcss:watch\n"
4349
else

0 commit comments

Comments
 (0)