diff --git a/docs/guide/index.md b/docs/guide/index.md index 0ab8f55..36d6324 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -8,6 +8,7 @@ Getting started - [Installation](installation.md) - [Bootstrap with Yii](bootstrap.md) +- [Configuration](configuration.md) Base concepts ============= @@ -17,8 +18,6 @@ Base concepts - [Model](model.md) - [View](view.md) - [Application](application.md) -- [Form](form.md) -- [Model validation reference](validation.md) Database ======== @@ -31,6 +30,8 @@ Database More ==== +- [Form](form.md) +- [Model validation reference](validation.md) - [Caching](caching.md) - [Internationalization](i18n.md) - [Extending Yii](extension.md) @@ -40,7 +41,7 @@ More - [URL Management](url.md) - [Theming](theming.md) - [Error Handling](error.md) -- [Template](template.md) +- [Using template engines](template.md) - [Console Application](console.md) - [Security](security.md) - [Performance Tuning](performance.md) diff --git a/docs/guide/template.md b/docs/guide/template.md index dc83d15..f2a6fc4 100644 --- a/docs/guide/template.md +++ b/docs/guide/template.md @@ -1,3 +1,86 @@ -Template -======== +Using template engines +====================== + +By default Yii uses PHP as template language but you can configure it to be able +to render templates with special engines such as Twig or Smarty. + +The component responsible for rendering a view is called `view`. You can add +a custom template engines as follows: + +```php +array( + 'components' => array( + 'view' => array( + 'class' => 'yii\base\View', + 'renderers' => array( + 'tpl' => array( + 'class' => 'yii\renderers\SmartyViewRenderer', + ), + 'twig' => array( + 'class' => 'yii\renderers\TwigViewRenderer', + 'twigPath' => '@app/vendors/Twig', + ), + // ... + ), + ), + ), +) +``` + +Note that Smarty and Twig are not bundled with Yii and you have to download and +unpack these yourself and then specify `twigPath` and `smartyPath` respectively. + +Twig +---- + +In order to use Twig you need to put you templates in files with extension `.twig` +(or another one if configured differently). +Also you need to specify this extension explicitly when calling `$this->render()` +or `$this->renderPartial()` from your controller: + +```php +echo $this->render('renderer.twig', array('username' => 'Alex')); +``` + +### Additional functions + +Additionally to regular Twig syntax the following is available in Yii: + +```php +{{ post.title }} +``` + +path function calls `Html::url()` internally. + +### Additional variables + +- `app` = `\Yii::$app` +- `this` = current `View` object + +Smarty +------ + +In order to use Smarty you need to put you templates in files with extension `.tpl` +(or another one if configured differently). +Also you need to specify this extension explicitly when calling `$this->render()` +or `$this->renderPartial()` from your controller: + +```php +echo $this->render('renderer.tpl', array('username' => 'Alex')); +``` + +### Additional functions + +Additionally to regular Smarty syntax the following is available in Yii: + +```php +{$post.title} +``` + +path function calls `Html::url()` internally. + +### Additional variables + +- `$app` = `\Yii::$app` +- `$this` = current `View` object diff --git a/docs/view_renderers.md b/docs/view_renderers.md deleted file mode 100644 index e26fe83..0000000 --- a/docs/view_renderers.md +++ /dev/null @@ -1,85 +0,0 @@ -Yii2 view renderers -=================== - -By default Yii uses PHP as template language but you can configure it to be able -to render templates with special engines such as Twig or Smarty. - -The component responsible for rendering a view is called `view`. You can add -a custom template engines as follows: - -```php -array( - 'components' => array( - 'view' => array( - 'class' => 'yii\base\View', - 'renderers' => array( - 'tpl' => array( - 'class' => 'yii\renderers\SmartyViewRenderer', - ), - 'twig' => array( - 'class' => 'yii\renderers\TwigViewRenderer', - 'twigPath' => '@app/vendors/Twig', - ), - // ... - ), - ), - ), -) -``` - -Note that Smarty and Twig are not bundled with Yii and you have to download and -unpack these yourself and then specify `twigPath` and `smartyPath` respectively. - -Twig ----- - -In order to use Twig you need to put you templates in files with extension `.twig` -(or another one if configured differently). -Also you need to specify this extension explicitly when calling `$this->render()` -or `$this->renderPartial()` from your controller: - -```php -echo $this->render('renderer.twig', array('username' => 'Alex')); -``` - -### Additional functions - -Additionally to regular Twig syntax the following is available in Yii: - -```php -{{ post.title }} -``` - -path function calls `Html::url()` internally. - -### Additional variables - -- `app` = `\Yii::$app` -- `this` = current `View` object - -Smarty ------- - -In order to use Smarty you need to put you templates in files with extension `.tpl` -(or another one if configured differently). -Also you need to specify this extension explicitly when calling `$this->render()` -or `$this->renderPartial()` from your controller: - -```php -echo $this->render('renderer.tpl', array('username' => 'Alex')); -``` - -### Additional functions - -Additionally to regular Smarty syntax the following is available in Yii: - -```php -{$post.title} -``` - -path function calls `Html::url()` internally. - -### Additional variables - -- `$app` = `\Yii::$app` -- `$this` = current `View` object \ No newline at end of file