commit 7f3127603af65f79bde6d5ce7f1587dd300c0ac4 Author: Joel Pittet Date: Sat Jun 28 21:19:15 2014 -0700 less preprocess diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 4cb31ca..7b372f7 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -50,6 +50,9 @@ public function getFilters() { // Array filters. new \Twig_SimpleFilter('without', 'twig_without'), + + // CSS class and ID filters. + new \Twig_SimpleFilter('class', 'drupal_html_class'), ); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index bc454b4..b7870bf 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -667,25 +667,6 @@ function template_preprocess_node(&$variables) { // Add article ARIA role. $variables['attributes']['role'] = 'article'; - - // Gather node classes. - $variables['attributes']['class'][] = ''; - - $variables['node_type'] = drupal_html_class($node->bundle()); - $variables['view_mode'] = drupal_html_class($variables['view_mode']); - - if ($node->isPromoted()) { - $variables['node_promoted'] = TRUE; - } - if ($node->isSticky()) { - $variables['node_sticky'] = TRUE; - } - if (!$node->isPublished()) { - $variables['node_unpublished'] = TRUE; - } - if (isset($variables['preview'])) { - $variables['node_preview'] = TRUE; - } } /** diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index c002230..4294859 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -79,16 +79,15 @@ #} {% set classes = [ 'node', - 'node--type-' ~ node_type, - node_promoted ? 'node--promoted', - node_sticky ? 'node--sticky', - node_unpublished ? 'node--unpublished', - node_preview ? 'node--preview', - 'node--view-mode-' ~ view_mode + 'node--type-' ~ node.bundle|class, + node.promoted ? 'node--promoted', + node.sticky ? 'node--sticky', + not node.published ? 'node--unpublished', + preview ? 'node--preview', + 'node--view-mode-' ~ view_mode|class ] %} - -
+
{{ title_prefix }} {% if not page %} diff --git a/core/modules/system/src/Tests/Theme/TwigFilterTest.php b/core/modules/system/src/Tests/Theme/TwigFilterTest.php index 9b514d7..c132f94 100644 --- a/core/modules/system/src/Tests/Theme/TwigFilterTest.php +++ b/core/modules/system/src/Tests/Theme/TwigFilterTest.php @@ -120,6 +120,10 @@ public function testTwigWithoutFilter() { 'expected' => '
All attributes again.
', 'message' => 'All attributes printed again.', ), + array( + 'expected' => '
ID and class.
', + 'message' => 'Class and ID filtered.', + ), ); foreach ($elements as $element) { diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig index 28e5c15..a0979dd 100644 --- a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig +++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig @@ -20,3 +20,4 @@
Without string attribute.
Without either nor class attributes.
All attributes again.
+