commit 9339bd07f5bf13080335eedf558099b8829aa3d4 Author: Jen Lampton Date: Sun Jul 21 12:48:11 2013 -0700 remove toolbar-tab-wrapper.html.twig diff --git a/core/modules/toolbar/templates/toolbar-tab-wrapper.html.twig b/core/modules/toolbar/templates/toolbar-tab-wrapper.html.twig deleted file mode 100644 index 268b08f..0000000 --- a/core/modules/toolbar/templates/toolbar-tab-wrapper.html.twig +++ /dev/null @@ -1,19 +0,0 @@ -{# -/** - * Default theme implementation for a toolbar tab wrapper. - * - * Toolbar tabs have a common styling and placement within the toolbar's bar - * area. - * - * Available variables: - * - children: The content of the toolbar tab. - * - attributes: HTML attributes to apply to the wrapper. - * - * @see template_preprocess_toolbar_tab_wrapper() - * - * @ingroup themeable - */ -#} -{% if children %} - {{ children }} -{% endif %} diff --git a/core/modules/toolbar/templates/toolbar.html.twig b/core/modules/toolbar/templates/toolbar.html.twig index 80bbaa0..d48144a 100644 --- a/core/modules/toolbar/templates/toolbar.html.twig +++ b/core/modules/toolbar/templates/toolbar.html.twig @@ -6,7 +6,9 @@ * - attributes: HTML attributes for the wrapper. * - toolbar_attributes: HTML attributes to apply to the toolbar. * - toolbar_heading: The heading or label for the toolbar. - * - children: Tabs for the toolbar. + * - tabs: List of tabs for the toolbar. + * - tab.attributes: HTML Attributes for the tab container. + * - tab.link: Link or button for the menu tab. * - trays: Toolbar trays, each associated with a tab. * * @see template_preprocess_toolbar() @@ -18,7 +20,9 @@

{{ toolbar_heading }}

- {{ children }} + {% for tab in tabs %} +
{{ tab.link }}
+ {% endfor %} {{ trays }} diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 737a27e..51db39e 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -49,11 +49,6 @@ function toolbar_theme($existing, $type, $theme, $path) { ); $items['toolbar_item'] = array( 'render element' => 'element', - 'template' => 'toolbar-item', - ); - $items['toolbar_tab_wrapper'] = array( - 'render element' => 'element', - 'template' => 'toolbar-tab-wrapper', ); $items['toolbar_tray_wrapper'] = array( 'render element' => 'element', @@ -103,7 +98,6 @@ function toolbar_element_info() { $elements['toolbar_item'] = array( '#pre_render' => array('toolbar_pre_render_item'), '#theme' => 'toolbar_item', - '#theme_wrappers' => array('toolbar_tab_wrapper'), 'tab' => array( '#type' => 'link', '#title' => NULL, @@ -228,22 +222,46 @@ function ($object) { * the tray. Properties used: #children, #attributes and #bar. */ function template_preprocess_toolbar(&$variables) { - if (!empty($variables['element']['#children'])) { - $element = $variables['element']; - $variables['attributes'] = $element['#attributes']; - $variables['toolbar_attributes'] = new Attribute($element['#bar']['#attributes']); - $variables['toolbar_heading'] = $element['#bar']['#heading']; - $variables['children'] = $element['#children']; - $variables['trays'] = array(); - foreach (element_children($element) as $key) { - if (isset($element[$key]['tray'])) { - $variables['trays'][$key] = $element[$key]['tray']; - } + $element = $variables['element']; + + // Prepare the toolbar attributes. + $variables['attributes'] = $element['#attributes']; + $variables['toolbar_attributes'] = new Attribute($element['#bar']['#attributes']); + $variables['toolbar_heading'] = $element['#bar']['#heading']; + + $variables['children'] = $element['#children']; + + // Prepaare the trays and tabs for each toolbar item. + $variables['trays'] = array(); + $variables['tabs'] = array(); + foreach (element_children($element) as $key) { + // Add the tray. + if (isset($element[$key]['tray'])) { + $variables['trays'][$key] = $element[$key]['tray']; + unset($element[$key]['tray']); + } + + // Pass the wrapper attributes along. + if (array_key_exists('#wrapper_attributes', $element[$key])) { + $element[$key]['#wrapper_attributes']['class'][] = 'toolbar-tab'; + $attributes = $element[$key]['#wrapper_attributes']; + } + else { + $attributes = array('class' => array('toolbar-tab')); } + // Add the tab. + $variables['tabs'][$key] = array( + 'link' => $element[$key]['tab'], + 'attributes' => new Attribute($attributes), + ); } } +function theme_toolbar_item(&$variables) { + return drupal_render($variables['element']['tab']); +} + /** * Provides markup for associating a tray trigger with a tray element. * @@ -321,27 +339,6 @@ function template_preprocess_toolbar_item(&$variables) { } /** - * Prepares variables for toolbar tab wrapper templates. - * - * Default template: toolbar-tab-wrapper.html.twig. - * - * Toolbar tabs have a common styling and placement with the toolbar's bar area. - * - * @param array $variables - * An associative array containing: - * - element: An associative array containing the properties and children of - * the tray. Properties used: #children and #attributes. - */ -function template_preprocess_toolbar_tab_wrapper(&$variables) { - $variables['children'] = NULL; - if (!empty($variables['element']['#children'])) { - $variables['element']['#wrapper_attributes']['class'][] = 'toolbar-tab'; - $variables['attributes'] = $variables['element']['#wrapper_attributes']; - $variables['children'] = $variables['element']['#children']; - } -} - -/** * Prepares variables for toolbar tray wrapper templates. * * Default template: toolbar-tray-wrapper.html.twig.