commit c15131dd82f90a0b75996d7f5f1585d03a3cec30 Author: Joel Pittet Date: Thu Nov 21 17:22:55 2013 -0800 cleanup, docs, remove twig_show diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index ed616db..250dff3 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -17,6 +17,10 @@ * @see \Drupal\Core\CoreServiceProvider */ class TwigExtension extends \Twig_Extension { + + /** + * {@inheritdoc} + */ public function getFunctions() { return array( // @todo Remove URL function once http://drupal.org/node/1778610 is resolved. @@ -26,6 +30,9 @@ public function getFunctions() { ); } + /** + * {@inheritdoc} + */ public function getFilters() { return array( 't' => new \Twig_Filter_Function('t'), @@ -42,6 +49,9 @@ public function getFilters() { ); } + /** + * {@inheritdoc} + */ public function getNodeVisitors() { // The node visitor is needed to wrap all variables with // render_var -> twig_render_var() function. @@ -50,14 +60,13 @@ public function getNodeVisitors() { ); } + /** + * {@inheritdoc} + */ public function getTokenParsers() { return array( new TwigTransTokenParser(), ); } - - public function getName() { - return 'drupal_core'; - } } diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index 0e62158..17e64f7 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -131,32 +131,27 @@ function twig_render_var($arg) { } /** - * Wrapper around hide() that does not return the content. + * Sets a child's #printed property to TRUE to prevent it from rendering. * - * @see hide + * @param mixed $element + * The parent renderable array to hide the child items. + * @param string[] $args,... + * The string keys of $element to prevent printing. + * + * @return mixed + * String, Object or Render Array */ function twig_hide($element) { if ($element instanceof TwigReference) { $args = func_get_args(); if (count($args) > 1) { - array_shift($args); - foreach($args as $arg) { - if (isset($element[$arg])) $element[$arg]['#printed'] = TRUE; + unset($args[0]); + foreach ($args as $arg) { + if (isset($element[$arg])) { + $element[$arg]['#printed'] = TRUE; + } } } } return $element; } - -/** - * Wrapper around show() that does not return the content. - * - * @see show - */ -function twig_show($element) { - if ($element instanceof TwigReference) { - $element = &$element->getReference(); - show($element); - } - // @todo Add warning in else case -}