From cdad8d7f4ffa3cbc6f0dccbfa563a15a80ef3901 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 10 Sep 2014 10:56:30 +0100
Subject: [PATCH] Issue #2329775 by lauriii | davidhernandez: Move taxonomy
 term classes from preprocess to templates.

---
 core/modules/taxonomy/taxonomy.module                   | 5 -----
 core/modules/taxonomy/templates/taxonomy-term.html.twig | 9 ++++++++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 4701e26548d4..aa3dc9584eba 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -319,11 +319,6 @@ function template_preprocess_taxonomy_term(&$variables) {
   foreach (Element::children($variables['elements']) as $key) {
     $variables['content'][$key] = $variables['elements'][$key];
   }
-
-  // Gather classes, and clean up name so there are no underscores.
-  $variables['attributes']['class'][] = 'taxonomy-term';
-  $vocabulary_name_css = str_replace('_', '-', $term->bundle());
-  $variables['attributes']['class'][] = 'vocabulary-' . $vocabulary_name_css;
 }
 
 /**
diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig
index 2ecc7135dd7f..76fc81cbf34d 100644
--- a/core/modules/taxonomy/templates/taxonomy-term.html.twig
+++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig
@@ -22,6 +22,7 @@
  * - page: Flag for the full page state.
  * - term: The taxonomy term entity, including:
  *   - id: The ID of the taxonomy term.
+ *   - bundle: Machine name of the current vocabulary.
  * - view_mode: View mode, e.g. 'full', 'teaser', etc.
  *
  * @see template_preprocess_taxonomy_term()
@@ -29,7 +30,13 @@
  * @ingroup themeable
  */
 #}
-<div id="taxonomy-term-{{ term.id }}"{{ attributes }}>
+{%
+  set classes = [
+    'taxonomy-term',
+    'vocabulary-' ~ term.bundle|clean_class,
+  ]
+%}
+<div id="taxonomy-term-{{ term.id }}"{{ attributes.addClass(classes)|without('id') }}>
   {{ title_prefix }}
   {% if not page %}
     <h2><a href="{{ url }}">{{ name }}</a></h2>
-- 
GitLab