twig: ability to specify options

This commit is contained in:
Alexander Makarov
2013-02-08 03:38:08 +04:00
parent bb5962f9f5
commit 1d6b8d856c

View File

@@ -24,6 +24,12 @@ class TwigViewRenderer extends ViewRenderer
public $cacheDir = '@app/runtime/Twig/cache'; public $cacheDir = '@app/runtime/Twig/cache';
public $fileExtension = 'twig'; public $fileExtension = 'twig';
/**
* @var array options
* @see http://twig.sensiolabs.org/doc/api.html#environment-options
*/
public $options = array();
/** /**
* @var \Twig_Environment * @var \Twig_Environment
*/ */
@@ -34,9 +40,10 @@ class TwigViewRenderer extends ViewRenderer
\Yii::setAlias('@Twig', $this->twigDir); \Yii::setAlias('@Twig', $this->twigDir);
$loader = new \Twig_Loader_String(); $loader = new \Twig_Loader_String();
$this->_twig = new \Twig_Environment($loader, array(
$this->_twig = new \Twig_Environment($loader, array_merge(array(
'cache' => \Yii::getAlias($this->cacheDir), 'cache' => \Yii::getAlias($this->cacheDir),
)); ), $this->options));
} }
/** /**