File tree Expand file tree Collapse file tree 2 files changed +8
-23
lines changed
Expand file tree Collapse file tree 2 files changed +8
-23
lines changed Original file line number Diff line number Diff line change 2222 if (!function_exists ('_render ' )) {
2323 function _render ($ template , $ context )
2424 {
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 );
2628 }
2729 }
2830
Original file line number Diff line number Diff line change @@ -17,34 +17,17 @@ class TwigParser
1717{
1818
1919 /**
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
4121 *
4222 * @param string $content
4323 * @param array $data
4424 * @return string
4525 */
4626 public function parse ($ content , $ data = [])
4727 {
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 );
4932 }
5033}
You can’t perform that action at this time.
0 commit comments