commit aebe033a3f500996dd53cdaed9857e96f60adcc0 Author: Joel Pittet Date: Wed May 7 23:08:08 2014 -0700 leave arrays as arrays and booleans as booleans, ftw! diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 5bfac2e..a2a333d 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2252,14 +2252,12 @@ function template_preprocess_maintenance_page(&$variables) { template_preprocess_page($variables); $page_object = $variables['page']['#page']; - $attributes = $page_object->getBodyAttributes(); - $classes = $attributes['class']; - $classes[] = 'maintenance-page'; - $classes[] = 'in-maintenance'; + $variables['attributes'] = $page_object->getBodyAttributes(); + $variables['attributes']['class'][] = 'maintenance-page'; + $variables['attributes']['class'][] = 'in-maintenance'; if (isset($variables['db_is_active']) && !$variables['db_is_active']) { - $classes[] = 'db-offline'; + $variables['attributes']['class'][] = 'db-offline'; } - $attributes['class'] = $classes; // @see system_page_build() $attached = array( @@ -2288,10 +2286,8 @@ function template_preprocess_install_page(&$variables) { template_preprocess_maintenance_page($variables); $page_object = $variables['page']['#page']; - $attributes = $page_object->getBodyAttributes(); - $classes = $attributes['class']; - $classes[] = 'install-page'; - $attributes['class'] = $classes; + $variables['attributes'] = $page_object->getBodyAttributes(); + $variables['attributes']['class'][] = 'install-page'; // Override the site name that is displayed on the page, since Drupal is // still in the process of being installed. diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index d2fa8bb..c3b3ad6 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -34,27 +34,15 @@ class Attribute extends \ArrayObject { /** - * Constructor - * - * Enforces that we have an array, and enforces parameter access to array - * elements. - * - * @param array $values - */ - public function __construct(array $values = null) { - if (null === $values) { - $values = array(); - } - parent::__construct($values, \ArrayObject::ARRAY_AS_PROPS); - } - - /** * Implements the magic __toString() method. */ public function __toString() { $return = ''; foreach ($this as $name => $value) { $rendered = NULL; + if ($value === NULL) { + continue; + } $name = String::checkPlain($name); if (is_array($value)) { $rendered = $name . '="' . String::checkPlain(implode(' ', $value)) . '"'; @@ -71,25 +59,4 @@ public function __toString() { } return $return; } - - /** - * Implements the magic __call() method. - */ - public function __call($name, $arguments) { - $rendered = NULL; - if (isset($this[$name])) { - $value = $this[$name]; - if (is_array($value)) { - $rendered = String::checkPlain(implode(' ', $value)); - } - elseif (is_bool($value)) { - $rendered = ($value === FALSE) ? NULL : $name; - } - else { - $rendered = String::checkPlain($value); - } - } - return $rendered; - } - } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 9cc9a8b..2080fa4 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -437,7 +437,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array 'title' => '', 'href' => '', 'attributes' => array( - 'class' => 'hidden', + 'class' => array('hidden'), 'title' => t('Jump to the first new comment of this posting.'), 'data-history-node-last-comment-timestamp' => $node->get($field_name)->last_comment_timestamp, 'data-history-node-field-name' => $field_name, diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index ae1162e..c19db96 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -75,7 +75,7 @@ * @ingroup themeable */ #} -
+
{{ title_prefix }} {% if not page %} 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..c292ca1 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 @@ -13,10 +13,10 @@
All attributes:
-
Class attributes in front, remainder at the back:
-
Class attributes in back, remainder at the front:
-
Class attributes only:
-
Without boolean attribute.
+
Class attributes in front, remainder at the back:
+
Class attributes in back, remainder at the front:
+
Class attributes only:
+
Without boolean attribute.
Without string attribute.
Without either nor class attributes.
All attributes again.
diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index d2c4584..b034351 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -62,7 +62,7 @@ * @see template_preprocess_comment() */ #} -
+
diff --git a/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig index fad1ed7..40545cc 100644 --- a/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig +++ b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig @@ -16,7 +16,7 @@ * @see bartik_preprocess_field() */ #} -
+
{{ label }}: