Fix BetterHtml::DontInterpolateHere in _flash.html.erb

Move flash type conditionals to local variables above the tag so
role/aria-live use <%= %> expressions instead of <% %> statements
inside the tag. Also remove unsupported aria_hidden: kwarg from
svg_icon calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pull/599/head
Marcelo Paiva 3 weeks ago
parent 89a7783233
commit 921d5d8e82

@ -1,11 +1,13 @@
<% flash_role = flash[:notice] ? 'status' : 'alert' %>
<% flash_live = flash[:notice] ? 'polite' : 'assertive' %>
<div id="flash" class="absolute top-0 w-full h-0 z-20"> <div id="flash" class="absolute top-0 w-full h-0 z-20">
<div class="max-w-xl mx-auto mt-1.5"> <div class="max-w-xl mx-auto mt-1.5">
<div class="px-4 py-3 rounded-2xl bg-base-200 flex items-center justify-between mx-4 md:mx-0" <% if flash[:notice] %>role="status" aria-live="polite" aria-atomic="true"<% else %>role="alert" aria-live="assertive" aria-atomic="true"<% end %>> <div class="px-4 py-3 rounded-2xl bg-base-200 flex items-center justify-between mx-4 md:mx-0" role="<%= flash_role %>" aria-live="<%= flash_live %>" aria-atomic="true">
<div class="flex items-center space-x-3"> <div class="flex items-center space-x-3">
<% if flash[:notice] %> <% if flash[:notice] %>
<%= svg_icon('info_circle', class: 'stroke-info flex-none w-6 h-6', aria_hidden: true) %> <%= svg_icon('info_circle', class: 'stroke-info flex-none w-6 h-6') %>
<% else %> <% else %>
<%= svg_icon('exclamation_circle', class: 'stroke-error flex-none w-6 h-6', aria_hidden: true) %> <%= svg_icon('exclamation_circle', class: 'stroke-error flex-none w-6 h-6') %>
<% end %> <% end %>
<div> <div>
<span><%= flash[:notice] || flash[:alert] %></span> <span><%= flash[:notice] || flash[:alert] %></span>

Loading…
Cancel
Save