4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
15 class Twig_Extension_StringLoader extends Twig_Extension
17 public function getFunctions()
20 new Twig_SimpleFunction('template_from_string', 'twig_template_from_string', array('needs_environment' => true)),
24 public function getName()
26 return 'string_loader';
31 * Loads a template from a string.
34 * {{ include(template_from_string("Hello {{ name }}")) }}
37 * @param Twig_Environment $env A Twig_Environment instance
38 * @param string $template A template as a string or object implementing __toString()
40 * @return Twig_Template
42 function twig_template_from_string(Twig_Environment $env, $template)
44 return $env->createTemplate((string) $template);
47 class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false);