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() {
|
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
|
||||||
|
|
||||||
$this->assertEquals("This is my templateThis is some contentFinal content",
|
Some more content
|
||||||
preg_replace("/\n?<!--.*-->\n?/U",'',$output));
|
Mixing content and Final final
|
||||||
|
content
|
||||||
|
SS;
|
||||||
|
|
||||||
|
$this->assertEquals($shouldbe, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicText() {
|
public function testBasicText() {
|
||||||
|
@ -3939,7 +3939,7 @@ class SSTemplateParser extends Parser {
|
|||||||
$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;
|
||||||
}
|
}
|
||||||
|
@ -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'] = '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user