Merge pull request #662 from silverstripe-rebelalliance/trac/7362

BUG 7362 dont include trailing space in bare string
This commit is contained in:
Hamish Friedlander 2012-07-22 20:45:39 -07:00
commit b70c45bcbe
3 changed files with 7 additions and 3 deletions

View File

@ -392,6 +392,10 @@ after')
$this->assertEquals('AD', $this->assertEquals('AD',
$this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% end_if %>D')); $this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% end_if %>D'));
// Bare words with ending space
$this->assertEquals('ABC',
$this->render('A<% if "RawVal" == RawVal %>B<% end_if %>C'));
// Else // Else
$this->assertEquals('ADE', $this->assertEquals('ADE',
$this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% else %>D<% end_if %>E')); $this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% else %>D<% end_if %>E'));
@ -457,7 +461,7 @@ after')
$this->assertEquals( $this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'), $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'),
'<p>A Bare String</p><p>B Bare String </p>' '<p>A Bare String</p><p>B Bare String</p>'
); );
$this->assertEquals( $this->assertEquals(

View File

@ -1146,7 +1146,7 @@ class SSTemplateParser extends Parser {
function Argument_FreeString(&$res, $sub) { function Argument_FreeString(&$res, $sub) {
$res['ArgumentMode'] = 'string'; $res['ArgumentMode'] = 'string';
$res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'"; $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
} }
/* ComparisonOperator: "==" | "!=" | "=" */ /* ComparisonOperator: "==" | "!=" | "=" */

View File

@ -322,7 +322,7 @@ class SSTemplateParser extends Parser {
function Argument_FreeString(&$res, $sub) { function Argument_FreeString(&$res, $sub) {
$res['ArgumentMode'] = 'string'; $res['ArgumentMode'] = 'string';
$res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'"; $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
} }
/*!* /*!*