ENHANCEMENT Allow multiline comments in SS3 templates

This commit is contained in:
miiihi 2013-03-05 16:22:09 +01:00 committed by Ingo Schommer
parent d83950bc2b
commit 5af35a89ce
3 changed files with 16 additions and 4 deletions

View File

@ -59,11 +59,23 @@ class SSViewerTest extends SapphireTest {
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
$this->assertEquals("This is my templateThis is some contentFinal content",
preg_replace("/\n?<!--.*-->\n?/U",'',$output));
Some more content
Mixing content and Final final
content
SS;
$this->assertEquals($shouldbe, $output);
}
public function testBasicText() {

View File

@ -3939,7 +3939,7 @@ class SSTemplateParser extends Parser {
$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 File

@ -947,7 +947,7 @@ class SSTemplateParser extends Parser {
# This is used to remove template comments
Comment: "<%--" (!"--%>" /./)+ "--%>"
Comment: "<%--" (!"--%>" /(?s)./)+ "--%>"
*/
function Comment__construct(&$res) {
$res['php'] = '';