diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 9cd17b0..28e96aa 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -17,18 +17,22 @@ * @see \Drupal\Core\CoreServiceProvider */ class TwigExtension extends \Twig_Extension { + + /** + * {@inheritdoc} + */ public function getFunctions() { - // @todo re-add unset => twig_unset if this is really needed return array( // @todo Remove URL function once http://drupal.org/node/1778610 is resolved. 'url' => new \Twig_Function_Function('url'), // These functions will receive a TwigReference object, if a render array is detected - 'hide' => new TwigReferenceFunction('twig_hide'), 'render_var' => new TwigReferenceFunction('twig_render_var'), - 'show' => new TwigReferenceFunction('twig_show'), ); } + /** + * {@inheritdoc} + */ public function getFilters() { return array( 't' => new \Twig_Filter_Function('t'), @@ -40,9 +44,14 @@ public function getFilters() { // @see TwigNodeTrans::compileString() 'passthrough' => new \Twig_Filter_Function('twig_raw_filter'), 'placeholder' => new \Twig_Filter_Function('twig_raw_filter'), + // @todo Consider renaming to 'exclude' or 'without'. + 'hide' => new \Twig_Filter_Function('twig_hide'), ); } + /** + * {@inheritdoc} + */ public function getNodeVisitors() { // The node visitor is needed to wrap all variables with // render_var -> twig_render_var() function. @@ -51,16 +60,16 @@ public function getNodeVisitors() { ); } + /** + * {@inheritdoc} + */ public function getTokenParsers() { return array( - new TwigFunctionTokenParser('hide'), - new TwigFunctionTokenParser('show'), new TwigTransTokenParser(), ); } - public function getName() - { + public function getName() { return 'drupal_core'; } } diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig index 873d192..fb5ee44 100644 --- a/core/modules/block/templates/block-list.html.twig +++ b/core/modules/block/templates/block-list.html.twig @@ -13,10 +13,9 @@ * @ingroup themeable */ #} -{% hide(form.place_blocks) %}
- {{ form }} + {{ form|hide('place_blocks') }}
{{ form.place_blocks }} diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 570448f..5e2b080 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -7,8 +7,7 @@ * - author: Comment author. Can be a link or plain text. * - content: The content-related items for the comment display. Use * {{ content }} to print them all, or print a subset such as - * {{ content.field_example }}. Use hide(content.field_example) to temporarily - * suppress the printing of a given element. + * {{ content.field_example }}. * - created: Formatted date and time for when the comment was created. * Preprocess functions can reformat it by calling format_date() with the * desired parameters on the 'comment.created' variable. @@ -93,8 +92,7 @@ {# We hide the links now so that we can render them later. #} - {% hide(content.links) %} - {{ content }} + {{ content|hide('links') }} {% if signature %}
diff --git a/core/modules/node/templates/node-edit-form.html.twig b/core/modules/node/templates/node-edit-form.html.twig index eee9ecc..510f0c0 100644 --- a/core/modules/node/templates/node-edit-form.html.twig +++ b/core/modules/node/templates/node-edit-form.html.twig @@ -15,11 +15,9 @@ * @ingroup themeable */ #} -{% hide(form.advanced) %} -{% hide(form.actions) %}
- {{ form }} + {{ form|hide('advanced', 'actions') }}
{{ form.advanced }} diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index 1f8c823..2099e3c 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -17,9 +17,7 @@ * - published: Whether the node is published. * - label: The title of the node. * - content: All node items. Use {{ content }} to print them all, - * or print a subset such as {{ content.field_example }}. Use - * {% hide(content.field_example) %} to temporarily suppress the printing - * of a given element. + * or print a subset such as {{ content.field_example }}. * - user_picture: The node author's picture from user-picture.html.twig. * - date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on @@ -94,8 +92,7 @@ {# We hide links now so that we can render them later. #} - {% hide(content.links) %} - {{ content }} + {{ content|hide('links') }}
{{ content.links }} diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig index a3986fa..13be3c9 100644 --- a/core/modules/taxonomy/templates/taxonomy-term.html.twig +++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig @@ -8,11 +8,7 @@ * - name: Name of the current term. * - content: Items for the content of the term (fields and description). * Use 'content' to print them all, or print a subset such as - * 'content.description'. Use the following code to temporarily suppress the - * printing of a given element: - * @code - * {% hide(content.description) %} - * @endcode + * 'content.description'. * - attributes: HTML attributes for the wrapper. The 'class' attribute * contains the following classes by default: * - taxonomy-term: The current template type, i.e. "theming hook". diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index ad03eb6..5e24380 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -7,8 +7,7 @@ * - author: Comment author. Can be a link or plain text. * - content: The content-related items for the comment display. Use * {{ content }} to print them all, or print a subset such as - * {{ content.field_example }}. Use hide(content.field_example) to temporarily - * suppress the printing of a given element. + * {{ content.field_example }}. * - created: Formatted date and time for when the comment was created. * Preprocess functions can reformat it by calling format_date() with the * desired parameters on the 'comment.created' variable. @@ -107,8 +106,7 @@ {# We hide the links now so that we can render them later. #} - {% hide(content.links) %} - {{ content }} + {{ content|hide('links') }}