From 5af35a89ce92e3452cfce19349e40a4a99debae4 Mon Sep 17 00:00:00 2001 From: miiihi Date: Tue, 5 Mar 2013 16:22:09 +0100 Subject: [PATCH] ENHANCEMENT Allow multiline comments in SS3 templates --- tests/view/SSViewerTest.php | 16 ++++++++++++++-- view/SSTemplateParser.php | 2 +- view/SSTemplateParser.php.inc | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index f816ba1ddd2..aae7951b0b6 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -59,11 +59,23 @@ public function testRequirements() { public function testComments() { $output = $this->render(<<This is some content<%-- this is another comment --%>Final content +<%-- Alone multi + line comment --%> +Some more content +Mixing content and <%-- multi + line comment --%> Final final +content SS ); + $shouldbe = <<assertEquals("This is my templateThis is some contentFinal content", - preg_replace("/\n?\n?/U",'',$output)); + $this->assertEquals($shouldbe, $output); } public function testBasicText() { diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index 08c319a08fc..d2f16a90ea0 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -3939,7 +3939,7 @@ function match_Comment ($stack = array()) { $result = $res_671; $this->pos = $pos_671; } - if (( $subres = $this->rx( '/./' ) ) !== FALSE) { $result["text"] .= $subres; } + if (( $subres = $this->rx( '/(?s)./' ) ) !== FALSE) { $result["text"] .= $subres; } else { $_673 = FALSE; break; } $_673 = TRUE; break; } diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc index 45a4650b4b2..151e24b6136 100644 --- a/view/SSTemplateParser.php.inc +++ b/view/SSTemplateParser.php.inc @@ -947,7 +947,7 @@ class SSTemplateParser extends Parser { # This is used to remove template comments - Comment: "<%--" (!"--%>" /./)+ "--%>" + Comment: "<%--" (!"--%>" /(?s)./)+ "--%>" */ function Comment__construct(&$res) { $res['php'] = '';