forked from y2i/yii2-fenom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewRenderer.php
40 lines (34 loc) · 985 Bytes
/
ViewRenderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace y2i\fenom;
use Yii;
use yii\base\View;
use yii\base\ViewRenderer as BaseViewRenderer;
class ViewRenderer extends BaseViewRenderer
{
/**
* @var string the directory, where stores templates.
*/
public $templatePath = '@app/views';
/**
* @var string the directory, where stores compiled templates in PHP files.
*/
public $compilePath = '@runtime/Fenom/compile';
/**
* @var int|array bit-mask or array of Fenom settings.
* @see https://github.com/bzick/fenom/blob/master/docs/en/configuration.md#template-settings
*/
public $options = 0;
/**
* @var \Fenom object that renders templates.
*/
public $fenom;
public function init()
{
$this->fenom = \Fenom::factory($this->templatePath, $this->compilePath, $this->options);
}
public function render($view, $file, $params)
{
$params['this'] = $view;
return $this->fenom->fetch($file, $params);
}
}