diff --git a/tests/templates/SSViewerTestCommentsFullSource.ss b/tests/templates/SSViewerTestCommentsFullSource.ss
new file mode 100644
index 000000000..82f008b01
--- /dev/null
+++ b/tests/templates/SSViewerTestCommentsFullSource.ss
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/tests/templates/SSViewerTestCommentsInclude.ss b/tests/templates/SSViewerTestCommentsInclude.ss
new file mode 100644
index 000000000..c709afed9
--- /dev/null
+++ b/tests/templates/SSViewerTestCommentsInclude.ss
@@ -0,0 +1 @@
+Included
\ No newline at end of file
diff --git a/tests/templates/SSViewerTestCommentsPartialSource.ss b/tests/templates/SSViewerTestCommentsPartialSource.ss
new file mode 100644
index 000000000..4b99e88ab
--- /dev/null
+++ b/tests/templates/SSViewerTestCommentsPartialSource.ss
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/templates/SSViewerTestCommentsWithInclude.ss b/tests/templates/SSViewerTestCommentsWithInclude.ss
new file mode 100644
index 000000000..3a3b50cde
--- /dev/null
+++ b/tests/templates/SSViewerTestCommentsWithInclude.ss
@@ -0,0 +1 @@
+<% include SSViewerTestCommentsInclude %>
\ No newline at end of file
diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php
index 08491951e..b86950923 100644
--- a/tests/view/SSViewerTest.php
+++ b/tests/view/SSViewerTest.php
@@ -1,6 +1,10 @@
process($data);
+ $expected = '
+
+
+
+
+';
+ $this->assertEquals($result, $expected);
+
+ $view = new SSViewer(array('SSViewerTestCommentsPartialSource'));
+ $data = new ArrayData(array());
+
+ $result = $view->process($data);
+ $expected = '';
+ $this->assertEquals($result, $expected);
+
+ $view = new SSViewer(array('SSViewerTestCommentsWithInclude'));
+ $data = new ArrayData(array());
+
+ $result = $view->process($data);
+ $expected = 'Included
';
+ $this->assertEquals($result, $expected);
+
+ SSViewer::set_source_file_comments(false);
+ }
}
diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php
index 5aebb1388..15caa835c 100644
--- a/view/SSTemplateParser.php
+++ b/view/SSTemplateParser.php
@@ -2949,7 +2949,7 @@ class SSTemplateParser extends Parser {
function ClosedBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
- $method = 'ClosedBlock_Handle_'.ucfirst(strtolower($blockname));
+ $method = 'ClosedBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are not supposed to close this block, or have mis-spelled it?', $this);
@@ -2981,6 +2981,7 @@ class SSTemplateParser extends Parser {
* @deprecated
*/
function ClosedBlock_Handle_Control(&$res) {
+ Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.');
return $this->ClosedBlock_Handle_Loop($res);
}
@@ -3086,7 +3087,7 @@ class SSTemplateParser extends Parser {
function OpenBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
- $method = 'OpenBlock_Handle_'.ucfirst(strtolower($blockname));
+ $method = 'OpenBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed the closing tag or have mis-spelled it?', $this);
@@ -3104,9 +3105,9 @@ class SSTemplateParser extends Parser {
if($this->includeDebuggingComments) { // Add include filename comments on dev sites
return
- '$val .= \'\';'. "\n".
- '$val .= SSViewer::parse_template('.$php.', $scope->getItem());'. "\n".
- '$val .= \'\';'. "\n";
+ '$val .= \'\';'. "\n".
+ '$val .= SSViewer::execute_template('.$php.', $scope->getItem());'. "\n".
+ '$val .= \'\';'. "\n";
}
else {
return
@@ -3930,7 +3931,8 @@ class SSTemplateParser extends Parser {
$code = preg_replace('/(]*>)/i', "\\1", $code);
$code = preg_replace('/(<\/html[^>]*>)/i', "\\1", $code);
} else {
- $code = "\n" . $code . "\n";
+ $code = str_replace('\';' . "\n", $code);
+ $code .= "\n" . '$val .= \'\';';
}
}
diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc
index 105555dec..2feae83b5 100644
--- a/view/SSTemplateParser.php.inc
+++ b/view/SSTemplateParser.php.inc
@@ -627,7 +627,7 @@ class SSTemplateParser extends Parser {
function ClosedBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
- $method = 'ClosedBlock_Handle_'.ucfirst(strtolower($blockname));
+ $method = 'ClosedBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are not supposed to close this block, or have mis-spelled it?', $this);
@@ -708,7 +708,7 @@ class SSTemplateParser extends Parser {
function OpenBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
- $method = 'OpenBlock_Handle_'.ucfirst(strtolower($blockname));
+ $method = 'OpenBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed the closing tag or have mis-spelled it?', $this);
@@ -726,9 +726,9 @@ class SSTemplateParser extends Parser {
if($this->includeDebuggingComments) { // Add include filename comments on dev sites
return
- '$val .= \'\';'. "\n".
- '$val .= SSViewer::parse_template('.$php.', $scope->getItem());'. "\n".
- '$val .= \'\';'. "\n";
+ '$val .= \'\';'. "\n".
+ '$val .= SSViewer::execute_template('.$php.', $scope->getItem());'. "\n".
+ '$val .= \'\';'. "\n";
}
else {
return
@@ -920,7 +920,8 @@ class SSTemplateParser extends Parser {
$code = preg_replace('/(]*>)/i', "\\1", $code);
$code = preg_replace('/(<\/html[^>]*>)/i', "\\1", $code);
} else {
- $code = "\n" . $code . "\n";
+ $code = str_replace('\';' . "\n", $code);
+ $code .= "\n" . '$val .= \'\';';
}
}