mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allow multiline comments in SS3 templates
This commit is contained in:
parent
d83950bc2b
commit
5af35a89ce
@ -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
|
||||
|
||||
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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ class SSTemplateParser extends Parser {
|
||||
|
||||
# This is used to remove template comments
|
||||
|
||||
Comment: "<%--" (!"--%>" /./)+ "--%>"
|
||||
Comment: "<%--" (!"--%>" /(?s)./)+ "--%>"
|
||||
*/
|
||||
function Comment__construct(&$res) {
|
||||
$res['php'] = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user