added array() function to cast as an array

This commit is contained in:
Andy Miller
2015-08-01 13:37:32 -06:00
parent a7e03c9d5c
commit 21beefd387

View File

@@ -78,6 +78,7 @@ class TwigExtension extends \Twig_Extension
new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new \Twig_SimpleFunction('gist', [$this, 'gistFunc']),
new \Twig_simpleFunction('random_string', [$this, 'randomStringFunc']),
new \Twig_SimpleFunction('array', [$this, 'arrayFunc']),
new \Twig_simpleFunction('t', [$this, 'translate']),
new \Twig_simpleFunction('ta', [$this, 'translateArray'])
];
@@ -481,6 +482,11 @@ class TwigExtension extends \Twig_Extension
return Utils::generateRandomString($count);
}
public function arrayFunc($value)
{
return (array) $value;
}
public function translateFunc()
{
return $this->grav['language']->translate(func_get_args());