Skip to content

Commit

Permalink
feature #2164 removed template source code for generated template cla…
Browse files Browse the repository at this point in the history
…sses when debug is disabled (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

removed template source code for generated template classes when debug is disabled

Commits
-------

7a04767 removed template source code for generated template classes when debug is disabled
  • Loading branch information
fabpot committed Oct 5, 2016
2 parents 75e4aa5 + 7a04767 commit 116e71e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* 1.26.1 (2016-XX-XX)

* removed template source code from generated template classes when debug is disabled
* fixed default implementation of Twig_Template::getDebugInfo() for better BC
* fixed regression on static calls for functions/filters/tests

Expand Down
2 changes: 1 addition & 1 deletion lib/Twig/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function tokenize($code, $filename = null)
mb_internal_encoding($mbEncoding);
}

return new Twig_TokenStream($this->tokens, $this->filename, $code);
return new Twig_TokenStream($this->tokens, $this->filename, $this->env->isDebug() ? $code : '');
}

protected function lexData()
Expand Down
12 changes: 12 additions & 0 deletions test/Twig/Tests/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
*/
class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
{
public function testStreamSource()
{
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$lexer = new Twig_Lexer($env);

$env->disableDebug();
$this->assertSame('', $lexer->tokenize('foo')->getSource());

$env->enableDebug();
$this->assertSame('foo', $lexer->tokenize('foo')->getSource());
}

public function testNameLabelForTag()
{
$template = '{% § %}';
Expand Down

0 comments on commit 116e71e

Please sign in to comment.