Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function renderTemplate(string $templateString, $context): string |
||
29 | { |
||
30 | $arrayContext = json_decode(json_encode($context), true); |
||
31 | // Prevents leaking global variable by forcing anonymous scope |
||
32 | $render = function($templateString, array $context) { |
||
33 | extract($context); |
||
34 | return eval('?>'.$templateString); |
||
35 | }; |
||
36 | |||
37 | ob_start(); |
||
38 | $render($templateString, $arrayContext); |
||
39 | $output = ob_get_clean(); |
||
40 | |||
41 | return $output; |
||
42 | } |
||
43 | } |
||
44 |