From d15961a44cb18b43fa5d75bebf9e07cb23b476af Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 19 Dec 2023 14:54:08 +0700 Subject: [PATCH] [#483] Fix the check for slim and erb layout files --- .template/variants/web/app/template.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.template/variants/web/app/template.rb b/.template/variants/web/app/template.rb index 108c6632..abc1ffdb 100644 --- a/.template/variants/web/app/template.rb +++ b/.template/variants/web/app/template.rb @@ -5,20 +5,20 @@ erb_layout_file = 'app/views/layouts/application.html.erb' slim_layout_file = 'app/views/layouts/application.html.slim' -layout_file = nil -layout_file = erb_layout_file if File.exist?(erb_layout_file) -layout_file = slim_layout_file if File.exist?(slim_layout_file) +erb_layout_exists = File.exist?(erb_layout_file) +slim_layout_exists = File.exist?(slim_layout_file) -if layout_file - insert_into_file layout_file, before: %r{} do +if erb_layout_exists + insert_into_file erb_layout_file, before: %r{} do <<~ERB.indent(2) <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> ERB end -else +# The slim layout (CRUD addon) already has the javascript include tag +elsif !slim_layout_exists @template_errors.add <<~ERROR - Cannot include javascript into `app/views/layouts/application.html.{erb|slim}` + Cannot include javascript into `app/views/layouts/application.html.erb` Content: <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> ERROR end @@ -40,12 +40,12 @@ RUBY end -if erb_layout_file - gsub_file 'app/views/layouts/application.html.erb', // do +if erb_layout_exists + gsub_file erb_layout_file, // do "" end # The slim layout (CRUD addon) already has the lang attribute -elsif slim_layout_file.blank? +elsif !erb_layout_exists @template_errors.add <<~ERROR Cannot insert the lang attribute into html tag into `app/views/layouts/application.html.erb` Content: