2ce3c9924935661d73253d58e631506a39726acb
[yaffs-website] / vendor / twig / twig / lib / Twig / Extension / StringLoader.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * @final
14  */
15 class Twig_Extension_StringLoader extends Twig_Extension
16 {
17     public function getFunctions()
18     {
19         return array(
20             new Twig_SimpleFunction('template_from_string', 'twig_template_from_string', array('needs_environment' => true)),
21         );
22     }
23
24     public function getName()
25     {
26         return 'string_loader';
27     }
28 }
29
30 /**
31  * Loads a template from a string.
32  *
33  * <pre>
34  * {{ include(template_from_string("Hello {{ name }}")) }}
35  * </pre>
36  *
37  * @param Twig_Environment $env      A Twig_Environment instance
38  * @param string           $template A template as a string or object implementing __toString()
39  *
40  * @return Twig_Template
41  */
42 function twig_template_from_string(Twig_Environment $env, $template)
43 {
44     return $env->createTemplate((string) $template);
45 }
46
47 class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false);