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
ffbdaa5d
Commit
ffbdaa5d
authored
Dec 12, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1487 from nergal/twig-viewrenderer
Add extensions support to yii\twig\ViewRenderer
parents
87291bd3
8b713632
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
ViewRenderer.php
extensions/yii/twig/ViewRenderer.php
+11
-0
No files found.
extensions/yii/twig/ViewRenderer.php
View file @
ffbdaa5d
...
@@ -28,6 +28,11 @@ class ViewRenderer extends BaseViewRenderer
...
@@ -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
...
@@ -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
));
}));
}));
...
...
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