From 60dbecdf8a3e3020249121a9d022b8a7151f2bed Mon Sep 17 00:00:00 2001 From: Travis Bradbury <travis.bradbury@orium.com> Date: Thu, 16 Jan 2025 15:33:51 -0800 Subject: [PATCH] Issue #3500401: Render other attributes in views_display_switch template. --- src/Plugin/views/area/DisplaySwitch.php | 3 +++ templates/views-display-switch.html.twig | 4 ++-- views_display_switch.module | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Plugin/views/area/DisplaySwitch.php b/src/Plugin/views/area/DisplaySwitch.php index e1050af..c8caaf6 100644 --- a/src/Plugin/views/area/DisplaySwitch.php +++ b/src/Plugin/views/area/DisplaySwitch.php @@ -230,6 +230,9 @@ class DisplaySwitch extends AreaPluginBase { return [ '#theme' => 'views_display_switch', '#links' => $links, + '#attributes' => [ + 'class' => ['views-display-switch'], + ], ]; } diff --git a/templates/views-display-switch.html.twig b/templates/views-display-switch.html.twig index 781d6cb..fcea87a 100644 --- a/templates/views-display-switch.html.twig +++ b/templates/views-display-switch.html.twig @@ -1,6 +1,6 @@ <!-- Add you custom twig html here --> -<div class="views-display-switch"> +<div {{ attributes }}> {% for link in links %} {{ link }} - {% endfor%} + {% endfor %} </div> diff --git a/views_display_switch.module b/views_display_switch.module index 047a8e8..a082516 100644 --- a/views_display_switch.module +++ b/views_display_switch.module @@ -33,6 +33,7 @@ function views_display_switch_theme() { 'render element' => 'children', 'variables' => [ 'links' => [], + 'attributes' => [], ], ], ]; -- GitLab