MINOR: moved includeDebuggingComments logic into own method to allow separated tests

This commit is contained in:
Zauberfisch 2013-04-22 14:12:43 +00:00
parent 7c66e8e7a2
commit 94b37f9c85
2 changed files with 40 additions and 22 deletions

View File

@ -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

View File

@ -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