]> git.openstreetmap.org Git - rails.git/commitdiff
Build pagination css classes without mutating arrays
authorAnton Khorev <tony29@yandex.ru>
Sun, 15 Oct 2023 19:41:55 +0000 (22:41 +0300)
committerAnton Khorev <tony29@yandex.ru>
Thu, 16 Nov 2023 10:21:14 +0000 (13:21 +0300)
app/views/browse/_paging_nav.html.erb

index 778f51a1f8c1591d45dbac7726263da232545d43..13cf7c2834423cdb31b549dfb22b00a597680975 100644 (file)
         width += 2 # padding width
         width += body.length
       end
-      link_classes = ["page-link"]
-      link_classes.push("px-1") if width > max_width_for_default_padding
+      link_classes = ["page-link", {"px-1" => width > max_width_for_default_padding}]
 
       pagination_items(pages, {}).each do |body, n|
         linked = !(n.is_a? String)
-        item_classes = ["page-item"]
-        item_classes.push(n) unless linked
     %>
-    <%= content_tag "li", :class => item_classes do
+    <%= content_tag "li", :class => ["page-item", {n => !linked}] do
           if linked
             link_to(body, url_for(page_param => n), :class => link_classes)
           else