function twig_without
twig_without($element)
Removes child elements from a copy of the original array.
Creates a copy of the renderable array and removes child elements by key specified through filter's arguments. The copy can be printed without these elements. The original renderable array is still available and can be used to print child elements in their entirety in the twig template.
Parameters
array|object $element: The parent renderable array to exclude the child items.
string[] $args, ...: The string keys of $element to prevent printing.
Return value
array The filtered renderable array.
File
- core/themes/engines/twig/twig.engine, line 140
- Handles integration of Twig templates with the Drupal theme system.
Code
function twig_without($element) { if ($element instanceof ArrayAccess) { $filtered_element = clone $element; } else { $filtered_element = $element; } $args = func_get_args(); unset($args[0]); foreach ($args as $arg) { if (isset($filtered_element[$arg])) { unset($filtered_element[$arg]); } } return $filtered_element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!themes!engines!twig!twig.engine/function/twig_without/8.1.x