Skip to content

Commit

Permalink
Makes error condition more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
malparty committed Jan 5, 2024
1 parent 3270c1d commit 0243e3d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .template/variants/web/app/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@

erb_layout_exists = File.exist?(erb_layout_file)
slim_layout_exists = File.exist?(slim_layout_file)
layout_not_found = !erb_layout_exists && !slim_layout_exists

if erb_layout_exists
insert_into_file erb_layout_file, before: %r{</head>} do
<<~ERB.indent(2)
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
ERB
end
# The slim layout (CRUD addon) already has the javascript include tag
elsif !slim_layout_exists
end

if layout_not_found
@template_errors.add <<~ERROR
Cannot include javascript into `app/views/layouts/application.html.erb`
Content: <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
Expand Down Expand Up @@ -44,8 +46,9 @@
gsub_file erb_layout_file, /<html>/ do
"<html lang='<%= I18n.locale %>'>"
end
# The slim layout (CRUD addon) already has the lang attribute
elsif !erb_layout_exists
end

if layout_not_found
@template_errors.add <<~ERROR
Cannot insert the lang attribute into html tag into `app/views/layouts/application.html.erb`
Content: <html lang='<%= I18n.locale %>'>
Expand Down

0 comments on commit 0243e3d

Please sign in to comment.