mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1726 from s-m/1487-fix-template-comments
BUG: Fix invalid code with source-file-comments, fixes #1487
This commit is contained in:
commit
85202876a9
@ -1068,10 +1068,10 @@ after')
|
|||||||
|
|
||||||
$result = $view->process($data);
|
$result = $view->process($data);
|
||||||
$expected = '<!doctype html>
|
$expected = '<!doctype html>
|
||||||
<html><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
|
<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --><html>
|
||||||
<head></head>
|
<head></head>
|
||||||
<body></body>
|
<body></body>
|
||||||
<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --></html>
|
</html><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
|
||||||
';
|
';
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
|
|
||||||
|
@ -1675,14 +1675,14 @@ class SSTemplateParser extends Parser {
|
|||||||
function If_ElseIfPart(&$res, $sub) {
|
function If_ElseIfPart(&$res, $sub) {
|
||||||
$res['php'] .=
|
$res['php'] .=
|
||||||
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
||||||
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
function If_ElsePart(&$res, $sub) {
|
function If_ElsePart(&$res, $sub) {
|
||||||
$res['php'] .=
|
$res['php'] .=
|
||||||
'else { ' . PHP_EOL .
|
'else { ' . PHP_EOL .
|
||||||
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4593,11 +4593,11 @@ class SSTemplateParser extends Parser {
|
|||||||
|
|
||||||
// Include top level debugging comments if desired
|
// Include top level debugging comments if desired
|
||||||
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
||||||
// If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE
|
// If this template is a full HTML page, then put the comments just outside the HTML tag,
|
||||||
// glitches
|
// this is still no problem for IE as long as the DOCTYPE-declaration is done before this comment
|
||||||
if(stripos($code, "<html") !== false) {
|
if(stripos($code, "<html") !== false) {
|
||||||
$code = preg_replace('/(<html[^>]*>)/i', "\\1<!-- template $templateName -->", $code);
|
$code = preg_replace('/(<html[^>]*>)/i', "<!-- template $templateName -->\\1", $code);
|
||||||
$code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->\\1", $code);
|
$code = preg_replace('/(<\/html[^>]*>)/i', "\\1<!-- end template $templateName -->", $code);
|
||||||
} else {
|
} else {
|
||||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||||
' -->\';' . "\n", $code);
|
' -->\';' . "\n", $code);
|
||||||
|
@ -1047,11 +1047,11 @@ class SSTemplateParser extends Parser {
|
|||||||
|
|
||||||
// Include top level debugging comments if desired
|
// Include top level debugging comments if desired
|
||||||
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
||||||
// If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE
|
// If this template is a full HTML page, then put the comments just outside the HTML tag,
|
||||||
// glitches
|
// this is still no problem for IE as long as the DOCTYPE-declaration is done before this comment
|
||||||
if(stripos($code, "<html") !== false) {
|
if(stripos($code, "<html") !== false) {
|
||||||
$code = preg_replace('/(<html[^>]*>)/i', "\\1<!-- template $templateName -->", $code);
|
$code = preg_replace('/(<html[^>]*>)/i', "<!-- template $templateName -->\\1", $code);
|
||||||
$code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->\\1", $code);
|
$code = preg_replace('/(<\/html[^>]*>)/i', "\\1<!-- end template $templateName -->", $code);
|
||||||
} else {
|
} else {
|
||||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||||
' -->\';' . "\n", $code);
|
' -->\';' . "\n", $code);
|
||||||
|
Loading…
Reference in New Issue
Block a user