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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
e6d5af03
Commit
e6d5af03
authored
Jun 19, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3878 from dapatrese/3877-twig-lexer-options-exception
Fixes Twig lexerOptions throwing exception (#3877)
parents
210a8e9a
48f941da
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
5 deletions
+23
-5
ViewRenderer.php
extensions/twig/ViewRenderer.php
+5
-5
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ViewRendererTest.php
tests/unit/extensions/twig/ViewRendererTest.php
+15
-0
layout.twig
tests/unit/extensions/twig/views/layout.twig
+2
-0
No files found.
extensions/twig/ViewRenderer.php
View file @
e6d5af03
...
...
@@ -104,11 +104,6 @@ class ViewRenderer extends BaseViewRenderer
$this
->
addExtensions
(
$this
->
extensions
);
}
// Change lexer syntax
if
(
!
empty
(
$this
->
lexerOptions
))
{
$this
->
setLexerOptions
(
$this
->
lexerOptions
);
}
// Adding global 'void' function (usage: {{void(App.clientScript.registerScriptFile(...))}})
$this
->
twig
->
addFunction
(
'void'
,
new
\Twig_Function_Function
(
function
(
$argument
)
{
}));
...
...
@@ -130,6 +125,11 @@ class ViewRenderer extends BaseViewRenderer
}));
$this
->
twig
->
addGlobal
(
'app'
,
\Yii
::
$app
);
// Change lexer syntax (must be set after other settings)
if
(
!
empty
(
$this
->
lexerOptions
))
{
$this
->
setLexerOptions
(
$this
->
lexerOptions
);
}
}
/**
...
...
framework/CHANGELOG.md
View file @
e6d5af03
...
...
@@ -54,6 +54,7 @@ Yii Framework 2 Change Log
-
Bug: Fixed inconsistent return of
`\yii\console\Application::runAction()`
(samdark)
-
Bug: URL encoding for the route parameter added to
`\yii\web\UrlManager`
(klimov-paul)
-
Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
-
Bug #3877 : Fixed Twig lexerOptions throwing exception
-
Enh #2264:
`CookieCollection::has()`
will return false for expired or removed cookies (qiangxue)
-
Enh #2435:
`yii\db\IntegrityException`
is now thrown on database integrity errors instead of general
`yii\db\Exception`
(samdark)
-
Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
...
...
tests/unit/extensions/twig/ViewRendererTest.php
View file @
e6d5af03
...
...
@@ -35,6 +35,18 @@ class ViewRendererTest extends TestCase
$this
->
assertEquals
(
1
,
preg_match
(
'#<script src="/assets/[0-9a-z]+/jquery\\.js"></script>\s*</body>#'
,
$content
),
'content does not contain the jquery js:'
.
$content
);
}
/**
* https://github.com/yiisoft/yii2/issues/3877
*/
public
function
testLexerOptions
()
{
$view
=
$this
->
mockView
();
$content
=
$view
->
renderFile
(
'@yiiunit/extensions/twig/views/layout.twig'
);
$this
->
assertFalse
(
strpos
(
$content
,
'CUSTOM_LEXER_TWIG_COMMENT'
)
,
'custom comment lexerOption is not applied'
);
$this
->
assertTrue
(
0
<
strpos
(
$content
,
'DEFAULT_TWIG_COMMENT'
)
,
'default comment style not modified via lexerOptions'
);
}
protected
function
mockView
()
{
return
new
View
([
...
...
@@ -52,6 +64,9 @@ class ViewRendererTest extends TestCase
'functions'
=>
[
't'
=>
'\Yii::t'
,
'json_encode'
=>
'\yii\helpers\Json::encode'
],
'lexerOptions'
=>
[
'tag_comment'
=>
[
'{*'
,
'*}'
],
]
],
],
...
...
tests/unit/extensions/twig/views/layout.twig
View file @
e6d5af03
...
...
@@ -8,6 +8,8 @@
</head>
<body>
{{
this.beginBody
()
}}
{# DEFAULT_TWIG_COMMENT #}
{* CUSTOM_LEXER_TWIG_COMMENT *}
body
{{
this.endBody
()
}}
</body>
...
...
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