|
|
@ -28,6 +28,11 @@ class ViewRenderer extends BaseViewRenderer |
|
|
|
public $cachePath = '@runtime/Twig/cache'; |
|
|
|
public $cachePath = '@runtime/Twig/cache'; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @var array extentions list. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $extensions = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @var array Twig options |
|
|
|
* @var array Twig options |
|
|
|
* @see http://twig.sensiolabs.org/doc/api.html#environment-options |
|
|
|
* @see http://twig.sensiolabs.org/doc/api.html#environment-options |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -46,6 +51,12 @@ class ViewRenderer extends BaseViewRenderer |
|
|
|
'cache' => Yii::getAlias($this->cachePath), |
|
|
|
'cache' => Yii::getAlias($this->cachePath), |
|
|
|
], $this->options)); |
|
|
|
], $this->options)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($this->extensions)) { |
|
|
|
|
|
|
|
foreach ($this->extensions as $extension) { |
|
|
|
|
|
|
|
$this->twig->addExtension(new $extension()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->twig->addFunction('path', new \Twig_Function_Function(function ($path, $args = []) { |
|
|
|
$this->twig->addFunction('path', new \Twig_Function_Function(function ($path, $args = []) { |
|
|
|
return Html::url(array_merge([$path], $args)); |
|
|
|
return Html::url(array_merge([$path], $args)); |
|
|
|
})); |
|
|
|
})); |
|
|
|