From 0328ff5c9ddc168da80f15ad9f29fb756b3fc9d3 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 14 Nov 2008 03:43:26 +0000 Subject: [PATCH] Added comment syntax to SS templates: <%-- ... --%> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65926 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/SSViewer.php | 1 + tests/SSViewerTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/core/SSViewer.php b/core/SSViewer.php index 5ef04e51d..00153dd28 100644 --- a/core/SSViewer.php +++ b/core/SSViewer.php @@ -355,6 +355,7 @@ class SSViewer extends Object { // $val, $val.property, $val(param), etc. $replacements = array( + '/<%--.*--%>/U' => '', '/\$Iteration/' => '', '/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)}/' => '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_]+)}/' => 'obj("\\1",array("\\2","\\3"),true)->XML_val("\\4",null,true) ?>', diff --git a/tests/SSViewerTest.php b/tests/SSViewerTest.php index e2a7e1f42..352e57a6b 100644 --- a/tests/SSViewerTest.php +++ b/tests/SSViewerTest.php @@ -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(<<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); + } } \ No newline at end of file