1: <?php
2:
3: namespace PHPixie\Template;
4:
5: class Renderer
6: {
7: protected $templateBuilder;
8: protected $slice;
9: protected $resolver;
10:
11: public function __construct($templateBuilder, $slice)
12: {
13: $this->templateBuilder = $templateBuilder;
14: $this->slice = $slice;
15: }
16:
17: public function render($name, $data) {
18: $arrayData = $this->slice->arrayData($data);
19: $context = $this->context($name, $arrayData);
20: $runtime = $this->runtime($context);
21: return $runtime->run();
22: }
23:
24: public function runtime($context)
25: {
26: return new Renderer\Runtime($context);
27: }
28:
29: public function context($template, $arrayData)
30: {
31: return new Renderer\Context(
32: $this->templateBuilder->extensions(),
33: $this,
34: $this->templateBuilder->resolver(),
35: $template,
36: $arrayData
37: );
38: }
39: }