Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
385f711f
Commit
385f711f
authored
Apr 27, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated view renderers docs
parent
d9498c43
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
view_renderers.md
docs/view_renderers.md
+33
-3
No files found.
docs/view_renderers.md
View file @
385f711f
...
@@ -2,17 +2,20 @@ Yii2 view renderers
...
@@ -2,17 +2,20 @@ Yii2 view renderers
===================
===================
By default Yii uses PHP as template language but you can change it in your application.
By default Yii uses PHP as template language but you can change it in your application.
The component responsible for rendering a view
using custom template enging is
The component responsible for rendering a view
is called
`view`
. You can configure
called
`viewRenderer`
. You can configure it
as follows:
a custom template engine
as follows:
```
php
```
php
array
(
array
(
'components'
=>
array
(
'components'
=>
array
(
'viewRenderer'
=>
array
(
'view'
=>
array
(
'class'
=>
'yii\base\View'
,
'renderer'
=>
array
(
'class'
=>
'yii\renderers\TwigViewRenderer'
,
'class'
=>
'yii\renderers\TwigViewRenderer'
,
// or 'class' => 'yii\renderers\SmartyViewRenderer',
// or 'class' => 'yii\renderers\SmartyViewRenderer',
),
),
),
),
),
)
)
```
```
...
@@ -29,3 +32,29 @@ Smarty
...
@@ -29,3 +32,29 @@ Smarty
In order to use Smarty you need to put you templates in files with extension
`.tpl`
.
In order to use Smarty you need to put you templates in files with extension
`.tpl`
.
Also you need to specify this extension explicitly when calling
`$this->render()`
Also you need to specify this extension explicitly when calling
`$this->render()`
or
`$this->renderPartial()`
from your controller.
or
`$this->renderPartial()`
from your controller.
Using multiple view renderers in a single application
-----------------------------------------------------
If you need multiple view renderers at the same time in a single application you
can use
`CompositeViewRenderer`
as follows:
```
php
'components'
=>
array
(
'view'
=>
array
(
'class'
=>
'yii\base\View'
,
'renderer'
=>
array
(
'class'
=>
'yii\renderers\CompositeViewRenderer'
,
'renderers'
=>
array
(
'tpl'
=>
array
(
'class'
=>
'yii\renderers\SmartyViewRenderer'
,
),
'twig'
=>
array
(
'class'
=>
'yii\renderers\TwigViewRenderer'
,
),
),
//'class' => 'yii\renderers\TwigViewRenderer',
),
),
),
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment