1 | <?php |
||
5 | class Renderer { |
||
6 | |||
7 | /** |
||
8 | * Array of engine definitions using |
||
9 | * file extension as key. |
||
10 | * |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $engines = [ |
||
14 | '.mustache.php' => 'Helmut\Forms\Engines\Mustache', |
||
15 | '.twig.php' => 'Helmut\Forms\Engines\Twig', |
||
16 | '.blade.php' => 'Helmut\Forms\Engines\Blade', |
||
17 | ]; |
||
18 | |||
19 | /** |
||
20 | * Cache of running engines. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $running = []; |
||
25 | |||
26 | /** |
||
27 | * Cache of template files. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $templates = []; |
||
32 | |||
33 | /** |
||
34 | * Add a new engine implementation. |
||
35 | * |
||
36 | * @param string $extension |
||
37 | * @param string $class |
||
38 | * @return void |
||
39 | */ |
||
40 | public function addEngine($extension, $class) |
||
44 | |||
45 | /** |
||
46 | * Get an engine implementation. |
||
47 | * |
||
48 | * @param string $key |
||
49 | * @return \Helmut\Forms\Engine |
||
50 | */ |
||
51 | 47 | public function start($key) |
|
59 | |||
60 | /** |
||
61 | * Get engine file extensions. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | 47 | public function extensions() |
|
69 | |||
70 | /** |
||
71 | * Create a template cache key. |
||
72 | * |
||
73 | * @param string $template |
||
74 | * @param array $paths |
||
75 | * @return string |
||
76 | */ |
||
77 | 47 | public function key($template, $paths) |
|
81 | |||
82 | /** |
||
83 | * Render a template. |
||
84 | * |
||
85 | * @param string $template |
||
86 | * @param array $properties |
||
87 | * @param array $paths |
||
88 | * @return string |
||
89 | */ |
||
90 | 47 | public function render($template, $properties, $paths) |
|
99 | |||
100 | /** |
||
101 | * Check if a template exists. |
||
102 | * |
||
103 | * @param string $template |
||
104 | * @param array $paths |
||
105 | * @return boolean |
||
106 | */ |
||
107 | public function has($template, $paths) |
||
111 | |||
112 | /** |
||
113 | * Find template file with engine. |
||
114 | * |
||
115 | * @param string $template |
||
116 | * @param array $paths |
||
117 | * @return array |
||
118 | */ |
||
119 | public function findTemplate($template, $paths) |
||
142 | |||
143 | } |
||
144 |