Added comment syntax to SS templates: <%-- ... --%>

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65926 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-14 03:43:26 +00:00
parent a25320a99c
commit 0328ff5c9d
2 changed files with 11 additions and 0 deletions

View File

@ -355,6 +355,7 @@ class SSViewer extends Object {
// $val, $val.property, $val(param), etc.
$replacements = array(
'/<%--.*--%>/U' => '',
'/\$Iteration/' => '<?= {dlr}key ?>',
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->obj("\\4",null,true)->XML_val("\\5",null,true) ?>',
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->XML_val("\\4",null,true) ?>',

View File

@ -33,4 +33,14 @@ SS
$template = $viewer->process($data);
$this->assertFalse((bool)trim($template), "Should be no content in this return.");
}
function testComments() {
$viewer = SSViewer::fromString(<<<SS
This is my template<%-- this is a comment --%>This is some content<%-- this is another comment --%>This is the final content
SS
);
$output = $viewer->process(new ArrayData(array()));
$this->assertEquals("This is my templateThis is some contentThis is the final content", $output);
}
}