1 | <?php |
||
12 | class Curty |
||
13 | { |
||
14 | private static $notFoundSymbol = null; |
||
15 | |||
16 | /** |
||
17 | * @var callable Callable to get values and object properties from contexts |
||
18 | */ |
||
19 | protected $get; |
||
20 | |||
21 | /** |
||
22 | * Create a Curty template renderer. |
||
23 | * |
||
24 | * @param callable Callable to get values and object properties from contexts |
||
25 | */ |
||
26 | public function __construct(callable $get = null) |
||
30 | |||
31 | /** |
||
32 | * Render template until a fixed point is reached. |
||
33 | * |
||
34 | * @param string $tpl Curty template |
||
35 | * @param object|array $context Variable mapping |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | public function __invoke(string $tpl, $context) : string |
||
48 | |||
49 | /** |
||
50 | * Render template. |
||
51 | * |
||
52 | * @param string $tpl Curty template |
||
53 | * @param object|array $context Variable mapping |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function render(string $tpl, $context) : string |
||
72 | |||
73 | protected function getValue(string $key, $context) |
||
84 | |||
85 | protected function renderValue($value) : string |
||
97 | |||
98 | protected static function getNotFoundSymbol() |
||
106 | } |
||
107 |