diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb index 707bbe5c..57e4fcc4 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/edit.html.erb @@ -1,7 +1,5 @@
- <%% if alert = flash[:alert] %> -

<%%= alert %>

- <%% end %> + <%%= render "flashes" %>

Update your password

diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb index 72c434de..db743016 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/passwords/new.html.erb @@ -1,7 +1,5 @@
- <%% if alert = flash[:alert] %> -

<%%= alert %>

- <%% end %> + <%%= render "flashes" %>

Forgot your password?

diff --git a/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb b/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb index 92d64b79..8a425512 100644 --- a/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb +++ b/lib/generators/tailwindcss/authentication/templates/app/views/sessions/new.html.erb @@ -1,11 +1,5 @@
- <%% if alert = flash[:alert] %> -

<%%= alert %>

- <%% end %> - - <%% if notice = flash[:notice] %> -

<%%= notice %>

- <%% end %> + <%%= render "flashes" %>

Sign in

diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 3d337f95..2b245cf3 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -1,9 +1,7 @@ <%% content_for :title, "<%= human_name.pluralize %>" %>
- <%% if notice.present? %> -

<%%= notice %>

- <%% end %> + <%%= render "flashes" %>

<%= human_name.pluralize %>

diff --git a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt index 3a49e9a0..cd90644b 100644 --- a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt @@ -1,9 +1,7 @@ <%% content_for :title, "Showing <%= human_name.downcase %>" %>
- <%% if notice.present? %> -

<%%= notice %>

- <%% end %> + <%%= render "flashes" %>

Showing <%= human_name.downcase %>

diff --git a/lib/install/_flashes.html.erb b/lib/install/_flashes.html.erb new file mode 100644 index 00000000..9e1ae4ef --- /dev/null +++ b/lib/install/_flashes.html.erb @@ -0,0 +1,7 @@ +<% if notice.present? %> +

<%= notice %>

+<% end %> + +<% if alert.present? %> +

<%= alert %>

+<% end %> diff --git a/lib/install/tailwindcss.rb b/lib/install/tailwindcss.rb index 2c2ba50c..db5dcb05 100644 --- a/lib/install/tailwindcss.rb +++ b/lib/install/tailwindcss.rb @@ -38,6 +38,12 @@ copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css" end +empty_directory "app/views/application" +unless Rails.root.join("app/views/application/_flashes.html.erb").exist? + say "Add default app/views/application/_flashes.html.erb" + copy_file "#{__dir__}/_flashes.html.erb", "app/views/application/_flashes.html.erb" +end + if Rails.root.join("Procfile.dev").exist? append_to_file "Procfile.dev", "css: bin/rails tailwindcss:watch\n" else