public TwigExtension::safeJoin(\Twig_Environment $env, $value, $glue = '')
Joins several strings together safely.
\Twig_Environment $env: A Twig_Environment instance.
mixed[]|\Traversable|NULL $value: The pieces to join.
string $glue: The delimiter with which to join the string. Defaults to an empty string. This value is expected to be safe for output and user provided data should never be used as a glue.
string The strings joined together.
public function safeJoin(\Twig_Environment $env, $value, $glue = '') { if ($value instanceof \Traversable) { $value = iterator_to_array($value, FALSE); } return implode($glue, array_map(function($item) use ($env) { // If $item is not marked safe then it will be escaped. return $this->escapeFilter($env, $item, 'html', NULL, TRUE); }, (array) $value)); }
© 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!lib!Drupal!Core!Template!TwigExtension.php/function/TwigExtension::safeJoin/8.1.x