README.md 830 Bytes
Newer Older
1 2
Twig Extension for Yii 2
========================
3

4
This extension provides a `ViewRender` that would allow you to use Twig view template engine.
5

6
To use this extension, simply add the following code in your application configuration:
7 8

```php
Alexander Makarov committed
9
return [
10
	//....
Alexander Makarov committed
11 12 13
	'components' => [
		'view' => [
			'renderers' => [
Carsten Brandt committed
14
				'twig' => [
15 16
					'class' => 'yii\twig\ViewRenderer',
					//'cachePath' => '@runtime/Twig/cache',
Alexander Makarov committed
17
					//'options' => [], /*  Array of twig options */
18
					// ... see ViewRenderer for more options
Alexander Makarov committed
19 20 21 22 23
				],
			],
		],
	],
];
24 25
```

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require yiisoft/yii2-twig "*"
```

or add

```
"yiisoft/yii2-twig": "*"
```

to the require section of your composer.json.