Permalink
Browse files

ENHANCEMENT Allow multiline comments in SS3 templates

  • Loading branch information...
1 parent d83950b commit 5af35a89ce92e3452cfce19349e40a4a99debae4 miiihi committed with chillu Mar 5, 2013
Showing with 16 additions and 4 deletions.
  1. +14 −2 tests/view/SSViewerTest.php
  2. +1 −1 view/SSTemplateParser.php
  3. +1 −1 view/SSTemplateParser.php.inc
View
16 tests/view/SSViewerTest.php
@@ -59,11 +59,23 @@ public function testRequirements() {
public function testComments() {
$output = $this->render(<<<SS
This is my template<%-- this is a comment --%>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 = <<<SS
+This is my templateThis is some contentFinal content
+
+Some more content
+Mixing content and Final final
+content
+SS;
- $this->assertEquals("This is my templateThis is some contentFinal content",
- preg_replace("/\n?<!--.*-->\n?/U",'',$output));
+ $this->assertEquals($shouldbe, $output);
}
public function testBasicText() {
View
2 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;
}
View
2 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'] = '';

0 comments on commit 5af35a8

Please sign in to comment.