diff --git a/src/Parser/Tokenizer.php b/src/Parser/Tokenizer.php index 28a5dbf..7f4be44 100644 --- a/src/Parser/Tokenizer.php +++ b/src/Parser/Tokenizer.php @@ -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; } diff --git a/tests/GeneralFormatterTest.php b/tests/GeneralFormatterTest.php index 60ba153..43cd148 100644 --- a/tests/GeneralFormatterTest.php +++ b/tests/GeneralFormatterTest.php @@ -176,6 +176,19 @@ public function testFormatDateCustom() { $this->assertEquals($this->stripTabs('
5th Oct
'), $this->stripTabs($template->output()->body)); } + public function testFormatDateCustomEscape() { + $xml = '
--
'; + + $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('
30th May 2017 at 10:52 am
'), $this->stripTabs($template->output($data)->body)); + } + /* * Nl2br Formatter Tests */