Disable all conversion inside verbatim section of template v2

This commit is contained in:
Kijin Sung 2025-08-18 22:24:48 +09:00
parent f7543e4c9a
commit 451d0b95ac
2 changed files with 35 additions and 1 deletions

View file

@ -138,9 +138,9 @@ class TemplateParser_v2
// Apply conversions.
$content = $this->_addContextSwitches($content);
$content = $this->_removeComments($content);
$content = $this->_convertVerbatimSections($content);
$content = $this->_convertRelativePaths($content);
$content = $this->_convertPHPSections($content);
$content = $this->_convertVerbatimSections($content);
$content = $this->_convertFragments($content);
$content = $this->_convertClassAliases($content);
$content = $this->_convertIncludes($content);

View file

@ -1115,6 +1115,40 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
'',
]);
$this->assertEquals($target, $this->_parse($source));
// @verbatim block inside @php block
$source = implode("\n", [
'@php',
'@verbatim',
'$foo = $bar->$baz;',
'@endverbatim',
'@endphp',
]);
$target = implode("\n", [
'<?php',
'',
'$foo = $bar->$baz;',
'',
'?>',
]);
$this->assertEquals($target, $this->_parse($source));
// @php block inside @verbatim block
$source = implode("\n", [
'@verbatim',
'@php',
'$foo = $bar->$baz;',
'@endphp',
'@endverbatim',
]);
$target = implode("\n", [
'',
'@php',
'$foo = $bar->$baz;',
'@endphp',
'',
]);
$this->assertEquals($target, $this->_parse($source));
}
public function testRawPhpCode()