File tree 2 files changed +8
-23
lines changed
2 files changed +8
-23
lines changed Original file line number Diff line number Diff line change 22
22
if (!function_exists ('_render ' )) {
23
23
function _render ($ template , $ context )
24
24
{
25
- return (new \Twig_Environment (new \Twig_Loader_String ))->render ($ template , $ context );
25
+ $ twig = new \Twig_Environment (new \Twig_Loader_Array (array ()));
26
+ $ template = $ twig ->createTemplate ($ template );
27
+ return $ template ->render ($ context );
26
28
}
27
29
}
28
30
Original file line number Diff line number Diff line change @@ -17,34 +17,17 @@ class TwigParser
17
17
{
18
18
19
19
/**
20
- * The Twig instance
21
- *
22
- * @var Bridge
23
- */
24
- protected $ twig ;
25
-
26
- /**
27
- * Create a new TwigParser instance
28
- *
29
- * @param UrlGenerator $url
30
- * @param Engine $parser
31
- * @param Request $request
32
- */
33
- public function __construct ()
34
- {
35
- $ this ->twig = new \Twig_Environment (new \Twig_Loader_String );
36
- $ this ->twig ->addExtension (new TwigExtension ());
37
- }
38
-
39
- /**
40
- * Parse data into the content
20
+ * Create a new TwigParser instance and parse data into the content
41
21
*
42
22
* @param string $content
43
23
* @param array $data
44
24
* @return string
45
25
*/
46
26
public function parse ($ content , $ data = [])
47
27
{
48
- return $ this ->twig ->render ($ content , $ data );
28
+ $ twig = new \Twig_Environment (new \Twig_Loader_Array (array ()));
29
+ $ twig ->addExtension (new TwigExtension ());
30
+ $ template = $ twig ->createTemplate ($ content );
31
+ $ subject = $ template ->render ($ data );
49
32
}
50
33
}
You can’t perform that action at this time.
0 commit comments