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
48f941da
Commit
48f941da
authored
Jun 15, 2014
by
patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes Twig lexerOptions throwing exception (#3877) and adds test for lexerOptions
parent
394ca05b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
ViewRenderer.php
extensions/twig/ViewRenderer.php
+5
-5
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ViewRendererTest.php
tests/unit/extensions/twig/ViewRendererTest.php
+12
-0
layout.twig
tests/unit/extensions/twig/views/layout.twig
+2
-0
No files found.
extensions/twig/ViewRenderer.php
View file @
48f941da
...
...
@@ -111,11 +111,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
)
{
}));
...
...
@@ -137,6 +132,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 @
48f941da
...
...
@@ -50,6 +50,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 @
48f941da
...
...
@@ -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
([
...
...
tests/unit/extensions/twig/views/layout.twig
View file @
48f941da
...
...
@@ -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