Skip to content

Commit

Permalink
ENHANCEMENT Allow multiline comments in SS3 templates
Browse files Browse the repository at this point in the history
  • Loading branch information
miiihi authored and chillu committed Mar 7, 2013
1 parent d83950b commit 5af35a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions tests/view/SSViewerTest.php
Expand Up @@ -59,11 +59,23 @@ public function testRequirements() {
public function testComments() { public function testComments() {
$output = $this->render(<<<SS $output = $this->render(<<<SS
This is my template<%-- this is a comment --%>This is some content<%-- this is another comment --%>Final content 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 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", $this->assertEquals($shouldbe, $output);
preg_replace("/\n?<!--.*-->\n?/U",'',$output));
} }


public function testBasicText() { public function testBasicText() {
Expand Down
2 changes: 1 addition & 1 deletion view/SSTemplateParser.php
Expand Up @@ -3939,7 +3939,7 @@ function match_Comment ($stack = array()) {
$result = $res_671; $result = $res_671;
$this->pos = $pos_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; } else { $_673 = FALSE; break; }
$_673 = TRUE; break; $_673 = TRUE; break;
} }
Expand Down
2 changes: 1 addition & 1 deletion view/SSTemplateParser.php.inc
Expand Up @@ -947,7 +947,7 @@ class SSTemplateParser extends Parser {
# This is used to remove template comments # This is used to remove template comments
Comment: "<%--" (!"--%>" /./)+ "--%>" Comment: "<%--" (!"--%>" /(?s)./)+ "--%>"
*/ */
function Comment__construct(&$res) { function Comment__construct(&$res) {
$res['php'] = ''; $res['php'] = '';
Expand Down

0 comments on commit 5af35a8

Please sign in to comment.