Issue #1963988 by joelpittet, Gaelan, chrisjlee: Convert theme_views_ui_view_preview_section() to Twig.

8.0.x
Alex Pott 2013-06-27 10:26:32 +01:00
parent 9d61e24b94
commit 7d267ffc43
3 changed files with 30 additions and 13 deletions

View File

@ -0,0 +1,20 @@
{#
/**
* @file
* Default theme implementation for a views UI preview section.
*
* Available variables:
* - title: The human readable section title.
* - links: A list of contextual links.
* - content: The content for this section preview.
*
* @see template_preprocess_views_ui_view_preview_section()
*
* @ingroup themeable
*/
#}
<h1 class="section-title">{{ title }}</h1>
{% if links %}
<div class="contextual">{{ links }}</div>
{% endif %}
<div class="preview-section">{{ content }}</div>

View File

@ -176,6 +176,7 @@ function views_ui_theme() {
'views_ui_view_preview_section' => array(
'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
'file' => 'views_ui.theme.inc',
'template' => 'views-ui-view-preview-section',
),
// Generic container wrapper, to use instead of theme_container when an id

View File

@ -389,7 +389,14 @@ function theme_views_ui_style_plugin_table($variables) {
}
/**
* Theme preprocess for theme_views_ui_view_preview_section().
* Prepares variables for views UI view preview section templates.
*
* Default template: views-ui-view-preview-section.html.twig.
*
* @param array $variables
* An associative array containing:
* - view: The view object.
* - section: The section name of a View (e.g. title, rows or pager).
*/
function template_preprocess_views_ui_view_preview_section(&$vars) {
switch ($vars['section']) {
@ -439,8 +446,6 @@ function template_preprocess_views_ui_view_preview_section(&$vars) {
if (isset($links)) {
$build = array(
'#prefix' => '<div class="contextual">',
'#suffix' => '</div>',
'#theme' => 'links__contextual',
'#links' => $links,
'#attributes' => array('class' => array('contextual-links')),
@ -448,16 +453,7 @@ function template_preprocess_views_ui_view_preview_section(&$vars) {
'library' => array(array('contextual', 'drupal.contextual-links')),
),
);
$vars['links'] = drupal_render($build);
$vars['links'] = $build;
}
$vars['theme_hook_suggestions'][] = 'views_ui_view_preview_section__' . $vars['section'];
}
/**
* Returns the HTML for a section of a View being previewed within the Views UI.
*/
function theme_views_ui_view_preview_section($vars) {
return '<h1 class="section-title">' . $vars['title'] . '</h1>'
. $vars['links']
. '<div class="preview-section">'. drupal_render($vars['content']) . '</div>';
}