Issue #2328913 by lanchez, lauriii, joelpittet | crowdcg: Move block classes out of preprocess and into templates.
parent
8c38be014c
commit
4d2c54d43e
|
@ -274,12 +274,6 @@ function template_preprocess_block(&$variables) {
|
|||
$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.
|
||||
if (!empty($variables['elements']['#id'])) {
|
||||
$variables['attributes']['id'] = drupal_html_id('block-' . $variables['elements']['#id']);
|
||||
|
|
|
@ -50,7 +50,7 @@ class BlockPreprocessUnitTest extends WebTestBase {
|
|||
// Test adding a class to the block content.
|
||||
$variables['content_attributes']['class'][] = 'test-class';
|
||||
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 @@ class BlockViewBuilderTest extends DrupalUnitTestBase {
|
|||
$entity = Block::load('test_block1');
|
||||
$output = entity_view($entity, 'block');
|
||||
$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[] = '';
|
||||
|
@ -110,7 +110,7 @@ class BlockViewBuilderTest extends DrupalUnitTestBase {
|
|||
$entity->save();
|
||||
$output = entity_view($entity, 'block');
|
||||
$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[] = ' <h2>Powered by Bananas</h2>';
|
||||
$expected[] = ' ';
|
||||
|
|
|
@ -21,13 +21,6 @@
|
|||
* - content: The content of this block.
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* - 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.
|
||||
* - content_attributes: HTML attributes for the content element.
|
||||
* - title_prefix: Additional output populated by modules, intended to be
|
||||
|
@ -41,14 +34,20 @@
|
|||
*/
|
||||
@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 }}
|
||||
{% if label %}
|
||||
<h2{{ title_attributes }}>{{ label }}</h2>
|
||||
{% endif %}
|
||||
{{ title_suffix }}
|
||||
|
||||
<div{{ content_attributes }}>
|
||||
<div{{ content_attributes.addClass('content') }}>
|
||||
{% block content %}
|
||||
{{ content }}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue