diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index 9c48c8e7f..acdb0c2ff 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -4590,19 +4590,20 @@ class SSTemplateParser extends Parser { // Get the result $code = $result['php']; } - + // Include top level debugging comments if desired if($includeDebuggingComments && $templateName && stripos($code, "]*>)/i', "\\1", $code); - $code = preg_replace('/(<\/html[^>]*>)/i', "\\1", $code); + // If this template contains a doctype, put it right after it, + // if not, put it after the tag to avoid IE glitches + if(stripos($code, "]*("[^"]")*[^>]*>)/im', "$1\r\n", $code); + } elseif(stripos($code, "]*>)/i', "$1", $code); } else { $code = str_replace('\';' . "\n", $code); - $code .= "\n" . '$val .= \'\';'; + ' -->\';' . "\r\n", $code); } + $code .= "\r\n" . '$val .= \'\';'; } return $code; diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc index ea01957c4..9aa35bd54 100644 --- a/view/SSTemplateParser.php.inc +++ b/view/SSTemplateParser.php.inc @@ -1044,19 +1044,20 @@ class SSTemplateParser extends Parser { // Get the result $code = $result['php']; } - + // Include top level debugging comments if desired if($includeDebuggingComments && $templateName && stripos($code, "]*>)/i', "\\1", $code); - $code = preg_replace('/(<\/html[^>]*>)/i', "\\1", $code); + // If this template contains a doctype, put it right after it, + // if not, put it after the tag to avoid IE glitches + if(stripos($code, "]*("[^"]")*[^>]*>)/im', "$1\r\n", $code); + } elseif(stripos($code, "]*>)/i', "$1", $code); } else { $code = str_replace('\';' . "\n", $code); - $code .= "\n" . '$val .= \'\';'; + ' -->\';' . "\r\n", $code); } + $code .= "\r\n" . '$val .= \'\';'; } return $code;