mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
Fix inlining of sources with CRLF
This commit is contained in:
@@ -641,7 +641,7 @@ class Twig_Environment
|
|||||||
$compiled = $this->compile($this->parse($this->tokenize($source, $name)), $source);
|
$compiled = $this->compile($this->parse($this->tokenize($source, $name)), $source);
|
||||||
|
|
||||||
if (isset($source[0])) {
|
if (isset($source[0])) {
|
||||||
$compiled .= '/* '.str_replace(array("\r\n", "\r", "\n"), "*/\n/* ", str_replace('*/', '*//*', $source))."*/\n";
|
$compiled .= '/* '.strtr($source, array('*/' => '*//*', "\r\n" => "*/\n/* ", "\r" => "*/\n/* ", "\n" => "*/\n/* "))."*/\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $compiled;
|
return $compiled;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
$twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
|
||||||
|
|
||||||
$source = "<? /*foo*/ ?>\nbar\n";
|
$source = "<? /*foo*/ ?>\r\nbar\n";
|
||||||
$expected = "/* <? /*foo*//* ?>*/\n/* bar*/\n/* */\n";
|
$expected = "/* <? /*foo*//* ?>*/\n/* bar*/\n/* */\n";
|
||||||
|
|
||||||
$this->assertContains($expected, $twig->compileSource($source, 'index'));
|
$this->assertContains($expected, $twig->compileSource($source, 'index'));
|
||||||
|
|||||||
Reference in New Issue
Block a user