mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: moved includeDebuggingComments logic into own method to allow separated tests
This commit is contained in:
parent
7c66e8e7a2
commit
94b37f9c85
@ -4593,21 +4593,30 @@ class SSTemplateParser extends Parser {
|
||||
|
||||
// Include top level debugging comments if desired
|
||||
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
||||
// If this template contains a doctype, put it right after it,
|
||||
// if not, put it after the <html> tag to avoid IE glitches
|
||||
if(stripos($code, "<!doctype") !== false) {
|
||||
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code);
|
||||
} elseif(stripos($code, "<html") !== false) {
|
||||
$code = preg_replace('/(<html[^>]*>)/i', "$1<!-- template $templateName -->", $code);
|
||||
} else {
|
||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||
' -->\';' . "\r\n", $code);
|
||||
}
|
||||
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
|
||||
$code = $parser->includeDebuggingComments($code, $templateName);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return string $code
|
||||
*/
|
||||
protected function includeDebuggingComments($code, $templateName) {
|
||||
// If this template contains a doctype, put it right after it,
|
||||
// if not, put it after the <html> tag to avoid IE glitches
|
||||
if(stripos($code, "<!doctype") !== false) {
|
||||
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code);
|
||||
} elseif(stripos($code, "<html") !== false) {
|
||||
$code = preg_replace('/(<html[^>]*>)/i', "$1<!-- template $templateName -->", $code);
|
||||
} else {
|
||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||
' -->\';' . "\r\n", $code);
|
||||
}
|
||||
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles some file that contains template source code, and returns the php code that will execute as per that
|
||||
|
@ -1047,21 +1047,30 @@ class SSTemplateParser extends Parser {
|
||||
|
||||
// Include top level debugging comments if desired
|
||||
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
||||
// If this template contains a doctype, put it right after it,
|
||||
// if not, put it after the <html> tag to avoid IE glitches
|
||||
if(stripos($code, "<!doctype") !== false) {
|
||||
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code);
|
||||
} elseif(stripos($code, "<html") !== false) {
|
||||
$code = preg_replace('/(<html[^>]*>)/i', "$1<!-- template $templateName -->", $code);
|
||||
} else {
|
||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||
' -->\';' . "\r\n", $code);
|
||||
}
|
||||
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
|
||||
$code = $parser->includeDebuggingComments($code, $templateName);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return string $code
|
||||
*/
|
||||
protected function includeDebuggingComments($code, $templateName) {
|
||||
// If this template contains a doctype, put it right after it,
|
||||
// if not, put it after the <html> tag to avoid IE glitches
|
||||
if(stripos($code, "<!doctype") !== false) {
|
||||
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code);
|
||||
} elseif(stripos($code, "<html") !== false) {
|
||||
$code = preg_replace('/(<html[^>]*>)/i', "$1<!-- template $templateName -->", $code);
|
||||
} else {
|
||||
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
|
||||
' -->\';' . "\r\n", $code);
|
||||
}
|
||||
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles some file that contains template source code, and returns the php code that will execute as per that
|
||||
|
Loading…
Reference in New Issue
Block a user