Commit 4d2c54d4 authored by alexpott's avatar alexpott
Browse files

Issue #2328913 by lanchez, lauriii, joelpittet | crowdcg: Move block classes...

Issue #2328913 by lanchez, lauriii, joelpittet | crowdcg: Move block classes out of preprocess and into templates.
parent 8c38be01
...@@ -274,12 +274,6 @@ function template_preprocess_block(&$variables) { ...@@ -274,12 +274,6 @@ function template_preprocess_block(&$variables) {
$variables['label'] = $variables['elements']['content']['#title']; $variables['label'] = $variables['elements']['content']['#title'];
} }
$variables['attributes']['class'][] = 'block';
$variables['attributes']['class'][] = drupal_html_class('block-' . $variables['configuration']['provider']);
// Add default class for block content.
$variables['content_attributes']['class'][] = 'content';
// Create a valid HTML ID and make sure it is unique. // Create a valid HTML ID and make sure it is unique.
if (!empty($variables['elements']['#id'])) { if (!empty($variables['elements']['#id'])) {
$variables['attributes']['id'] = drupal_html_id('block-' . $variables['elements']['#id']); $variables['attributes']['id'] = drupal_html_id('block-' . $variables['elements']['#id']);
......
...@@ -50,7 +50,7 @@ function testBlockClasses() { ...@@ -50,7 +50,7 @@ function testBlockClasses() {
// Test adding a class to the block content. // Test adding a class to the block content.
$variables['content_attributes']['class'][] = 'test-class'; $variables['content_attributes']['class'][] = 'test-class';
template_preprocess_block($variables); template_preprocess_block($variables);
$this->assertEqual($variables['content_attributes']['class'], array('test-class', 'content'), 'Default .content class added to block content_attributes'); $this->assertEqual($variables['content_attributes']['class'], array('test-class'), 'Test-class class added to block content_attributes');
} }
} }
...@@ -83,7 +83,7 @@ public function testBasicRendering() { ...@@ -83,7 +83,7 @@ public function testBasicRendering() {
$entity = Block::load('test_block1'); $entity = Block::load('test_block1');
$output = entity_view($entity, 'block'); $output = entity_view($entity, 'block');
$expected = array(); $expected = array();
$expected[] = '<div class="block block-block-test" id="block-test-block1">'; $expected[] = '<div id="block-test-block1" class="block block-block-test">';
$expected[] = ' '; $expected[] = ' ';
$expected[] = ' '; $expected[] = ' ';
$expected[] = ''; $expected[] = '';
...@@ -110,7 +110,7 @@ public function testBasicRendering() { ...@@ -110,7 +110,7 @@ public function testBasicRendering() {
$entity->save(); $entity->save();
$output = entity_view($entity, 'block'); $output = entity_view($entity, 'block');
$expected = array(); $expected = array();
$expected[] = '<div class="block block-block-test" id="block-test-block2">'; $expected[] = '<div id="block-test-block2" class="block block-block-test">';
$expected[] = ' '; $expected[] = ' ';
$expected[] = ' <h2>Powered by Bananas</h2>'; $expected[] = ' <h2>Powered by Bananas</h2>';
$expected[] = ' '; $expected[] = ' ';
......
...@@ -21,13 +21,6 @@ ...@@ -21,13 +21,6 @@
* - content: The content of this block. * - content: The content of this block.
* - attributes: HTML attributes for the containing element. * - attributes: HTML attributes for the containing element.
* - id: A valid HTML ID and guaranteed unique. * - id: A valid HTML ID and guaranteed unique.
* - class: Classes that can be used to style contextually through
* CSS. These can be manipulated through preprocess functions. The default
* values can be one or more of the following:
* - block: The current template type, i.e., "theming hook".
* - block-[module]: The module generating the block. For example, the user
* module is responsible for handling the default user navigation block.
* In that case the class would be 'block-user'.
* - title_attributes: HTML attributes for the title element. * - title_attributes: HTML attributes for the title element.
* - content_attributes: HTML attributes for the content element. * - content_attributes: HTML attributes for the content element.
* - title_prefix: Additional output populated by modules, intended to be * - title_prefix: Additional output populated by modules, intended to be
...@@ -41,14 +34,20 @@ ...@@ -41,14 +34,20 @@
*/ */
@todo Remove the div around content as per http://drupal.org/node/1972122. @todo Remove the div around content as per http://drupal.org/node/1972122.
#} #}
<div{{ attributes }}> {%
set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
]
%}
<div{{ attributes.addClass(classes) }}>
{{ title_prefix }} {{ title_prefix }}
{% if label %} {% if label %}
<h2{{ title_attributes }}>{{ label }}</h2> <h2{{ title_attributes }}>{{ label }}</h2>
{% endif %} {% endif %}
{{ title_suffix }} {{ title_suffix }}
<div{{ content_attributes }}> <div{{ content_attributes.addClass('content') }}>
{% block content %} {% block content %}
{{ content }} {{ content }}
{% endblock %} {% endblock %}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment