diff --git a/lib/generators/tailwindcss/authentication/authentication_generator.rb b/lib/generators/tailwindcss/authentication/authentication_generator.rb index aa6fc23..220a2fa 100644 --- a/lib/generators/tailwindcss/authentication/authentication_generator.rb +++ b/lib/generators/tailwindcss/authentication/authentication_generator.rb @@ -4,6 +4,10 @@ module Tailwindcss module Generators class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator source_root File.expand_path("templates", __dir__) + + def copy_view_files + template "../../scaffold/templates/_flashes.html.erb", "app/views/application/_flashes.html.erb" + end end end end 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 707bbe5..57e4fcc 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 72c434d..db74301 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 92d64b7..8a42551 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/scaffold_generator.rb b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb index 39c2da1..59d6fa7 100644 --- a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb +++ b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb @@ -24,6 +24,7 @@ def copy_view_files end template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_name}.html.erb") + template "_flashes.html.erb", "app/views/application/_flashes.html.erb" end private diff --git a/lib/generators/tailwindcss/scaffold/templates/_flashes.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_flashes.html.erb.tt new file mode 100644 index 0000000..9013ac7 --- /dev/null +++ b/lib/generators/tailwindcss/scaffold/templates/_flashes.html.erb.tt @@ -0,0 +1,7 @@ +<%% if notice.present? %> +

<%%= notice %>

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

<%%= alert %>

+<%% end %> diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 3d337f9..2b245cf 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 3a49e9a..cd90644 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 %>