Skip to content

Commit

Permalink
Fix #163 - Fix tokenizer removing all backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
solleer committed Jun 18, 2017
1 parent c878c6a commit c7ecd9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Parser/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ private function doStrings(&$tokens, $char, $i) {
if ($char === self::STRING) {
$string = $this->extractString($i);
$length = strlen($string)+1;
$char = $this->getChar($char);
$string = str_replace('\\' . $char, $char, $string);
$string = str_replace('\\' . $this->str[$i], $this->str[$i], $string);
$tokens[] = ['type' => self::STRING, 'value' => $string, 'line' => $this->lineNo];
return $length;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/GeneralFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ public function testFormatDateCustom() {
$this->assertEquals($this->stripTabs('<div>5th Oct</div>'), $this->stripTabs($template->output()->body));
}

public function testFormatDateCustomEscape() {
$xml = '<div class="created">--</div>';

$tss = '.created {
content: data(create_time);
format: date "jS M Y \\a\\t h:i a";
}';

$data['create_time'] = '2017-05-30 10:52:00';
$template = new Transphporm\Builder($xml, $tss);
$this->assertEquals($this->stripTabs('<div class="created">30th May 2017 at 10:52 am</div>'), $this->stripTabs($template->output($data)->body));
}

/*
* Nl2br Formatter Tests
*/
Expand Down

0 comments on commit c7ecd9e

Please sign in to comment.