commit d762f57498baca54137f85d2d44bd5a576a6d387 Author: Joel Pittet Date: Fri Nov 8 20:26:33 2013 -0800 no unset diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 220d0bc..ab69cb9 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -21,7 +21,6 @@ public function getFunctions() { return array( // @todo Remove URL function once http://drupal.org/node/1778610 is resolved. 'url' => new \Twig_Function_Function('url'), - 'unset' => new \Twig_Function_Function('unset'), // This functions will receive a TwigReference object, if a // render array is detected 'render_var' => new TwigReferenceFunction('twig_render_var'), diff --git a/core/modules/block/block.module b/core/modules/block/block.module index e1bc631..b25fd17 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -407,6 +407,20 @@ function block_list($region) { } /** + * Prepares variables for block list templates. + * + * Default template: block-list.html.twig. + * + * @param array $variables + * An associative array containing: + * - form: A render element representing the form. + */ +function template_preprocess_block_list(&$variables) { + $variables['place_blocks'] = $variables['form']['place_blocks']; + unset($variables['form']['place_blocks']); +} + +/** * Loads a block instance. * * This should only be used when entity_load() cannot be used directly. diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig index cfe1302..1900146 100644 --- a/core/modules/block/templates/block-list.html.twig +++ b/core/modules/block/templates/block-list.html.twig @@ -9,13 +9,11 @@ * * Available variables: * - form: The block add/edit form. + * - place_blocks: The list and filter form elements to place blocks. * * @ingroup themeable */ #} -{# We set and unset the place_blocks now so that we can render them later. #} -{% set place_blocks = form.place_blocks %} -{% unset(form.place_blocks) %}
{{ form }} diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 6ebafcb..de9fc87 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -91,9 +91,6 @@ - {# We remove links from content to render them later. #} - {% set links = content.links %} - {% unset(content.links) %} {{ content }} {% if signature %} diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 438104d..402c541 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -651,6 +651,13 @@ function template_preprocess_node(&$variables) { $variables['label'] = check_plain($node->label()); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); + // Helpful 'links' variable for templates. + $variables += array('links' => array()); + if (isset($variables['elements']['links'])) { + $variables['links'] = $variables['elements']['links']; + unset($variables['elements']['links']); + } + // Helpful $content variable for templates. $variables += array('content' => array()); foreach (element_children($variables['elements']) as $key) { @@ -758,6 +765,22 @@ function node_permission() { } /** + * Prepares variables for node edit form templates. + * + * Default template: node-edit-form.html.twig. + * + * @param array $variables + * An associative array containing: + * - form: A render element representing the form. + */ +function template_preprocess_node_edit_form(&$variables) { + $variables['advanced'] = $variables['form']['advanced']; + unset($variables['form']['advanced']); + $variables['actions'] = $variables['form']['actions']; + unset($variables['form']['actions']); +} + +/** * Implements hook_ranking(). */ function node_ranking() { diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index 6c82604..2913acf 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -639,7 +639,7 @@ function node_row_node_view_preprocess_node(&$variables) { $options = $variables['view']->rowPlugin->options; if (!$options['links']) { - unset($variables['content']['links']); + unset($variables['links']); } } diff --git a/core/modules/node/templates/node-edit-form.html.twig b/core/modules/node/templates/node-edit-form.html.twig index f4a77ed..a065b3c 100644 --- a/core/modules/node/templates/node-edit-form.html.twig +++ b/core/modules/node/templates/node-edit-form.html.twig @@ -15,10 +15,6 @@ * @ingroup themeable */ #} -{% set advanced = form.advanced %} -{% unset(form.actions) %} -{% set actions = form.actions %} -{% unset(form.actions) %}
{{ form }} diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index 9d5b259..67547ce 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -91,12 +91,10 @@ {% endif %} - {# We remove links now so that we can render them later. #} - {% set links = content.links %} - {% unset(content.links) %} {{ content }}
- - {{ links }} + {% if links %} + {{ links }} + {% endif %} diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 08cd24c..68033df 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -318,7 +318,7 @@ function rdf_preprocess_node(&$variables) { foreach ($valid_fields as $field_name) { $count += $variables['node']->get($field_name)->comment_count; // Annotates the 'x comments' link in teaser view. - if (isset($variables['content']['links']['comment__' . $field_name]['#links']['comment-comments'])) { + if (isset($variables['links']['comment__' . $field_name]['#links']['comment-comments'])) { $comment_count_attributes = rdf_rdfa_attributes($comment_count_mapping, $variables['node']->get($field_name)->comment_count); // According to RDFa parsing rule number 4, a new subject URI is created // from the href attribute if no rel/rev attribute is present. To get @@ -326,7 +326,7 @@ function rdf_preprocess_node(&$variables) { // container we set an empty rel attribute which triggers rule number 5. // See http://www.w3.org/TR/rdfa-syntax/#sec_5.5. $comment_count_attributes['rel'] = ''; - $variables['content']['links']['comment__' . $field_name]['#links']['comment-comments']['attributes'] += $comment_count_attributes; + $variables['links']['comment__' . $field_name]['#links']['comment-comments']['attributes'] += $comment_count_attributes; } } // In full node view, the number of comments is not displayed by diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index e334125..326a1b0 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -154,7 +154,7 @@ function bartik_preprocess_node(&$variables) { // Remove the "Add new comment" link on teasers or when the comment form is // displayed on the page. if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { - unset($variables['content']['links']['comment']['#links']['comment-add']); + unset($variables['links']['comment']['#links']['comment-add']); } } diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index 97824e9..0d8948d 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -105,9 +105,6 @@ {{ title_suffix }} - {# We remove links from content to render them later. #} - {% set links = content.links %} - {% unset(content.links) %} {{ content }}
diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig index e33fb0b..ea821fd 100644 --- a/core/themes/bartik/templates/node.html.twig +++ b/core/themes/bartik/templates/node.html.twig @@ -89,13 +89,10 @@
- {# We remove links from content to render them later. #} - {% set links = content.links %} - {% unset(content.links) %} {{ content }}
- {% if content.links %} + {% if links %}