mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-05-03 10:33:08 +03:00
parent
8392138584
commit
04f963a21f
@ -136,7 +136,6 @@ class Tokenizer
|
|||||||
*/
|
*/
|
||||||
$len = strlen($text);
|
$len = strlen($text);
|
||||||
for ($i = 0; $i < $len; $i++) {
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
|
||||||
$this->escaping = $this->tagChange(self::T_ESCAPE, $text, $i);
|
$this->escaping = $this->tagChange(self::T_ESCAPE, $text, $i);
|
||||||
|
|
||||||
// To play nice with helpers' arguments quote and apostrophe marks
|
// To play nice with helpers' arguments quote and apostrophe marks
|
||||||
@ -144,7 +143,7 @@ class Tokenizer
|
|||||||
$quoteInTag = $this->state != self::IN_TEXT
|
$quoteInTag = $this->state != self::IN_TEXT
|
||||||
&& ($text[$i] == self::T_SINGLE_Q || $text[$i] == self::T_DOUBLE_Q);
|
&& ($text[$i] == self::T_SINGLE_Q || $text[$i] == self::T_DOUBLE_Q);
|
||||||
|
|
||||||
if ($this->escaped && $text[$i] != self::T_UNESCAPED && !$quoteInTag) {
|
if ($this->escaped && !$this->tagChange($this->otag, $text, $i) && !$quoteInTag) {
|
||||||
$this->buffer .= "\\";
|
$this->buffer .= "\\";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +162,11 @@ class Tokenizer
|
|||||||
$this->flushBuffer();
|
$this->flushBuffer();
|
||||||
$this->state = self::IN_TAG_TYPE;
|
$this->state = self::IN_TAG_TYPE;
|
||||||
} elseif ($this->escaped and $this->escaping) {
|
} elseif ($this->escaped and $this->escaping) {
|
||||||
$this->buffer .= "\\";
|
// We should not add extra slash before opening tag because
|
||||||
|
// doubled slash where should be transformed to single one
|
||||||
|
if (($i + 1) < $len && !$this->tagChange($this->otag, $text, $i + 1)) {
|
||||||
|
$this->buffer .= "\\";
|
||||||
|
}
|
||||||
} elseif (!$this->escaping) {
|
} elseif (!$this->escaping) {
|
||||||
if ($text[$i] == "\n") {
|
if ($text[$i] == "\n") {
|
||||||
$this->filterLine();
|
$this->filterLine();
|
||||||
|
@ -118,32 +118,37 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
|
|||||||
'<strong>Test</strong>'
|
'<strong>Test</strong>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
"\{{data}}", // is equal to \\{{data}}
|
"\\{{data}}", // is equal to \{{data}} in template file
|
||||||
array('data' => 'foo'),
|
array('data' => 'foo'),
|
||||||
'{{data}}',
|
'{{data}}',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'\\\\{{data}}',
|
'\\\\{{data}}', // is equal to \\{{data}} in template file
|
||||||
array('data' => 'foo'),
|
array('data' => 'foo'),
|
||||||
'\\\\foo'
|
'\\foo' // is equals to \foo in output
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'\\\{{data}}', // is equal to \\\\{{data}} in php
|
'\{{{data}}}', // is equal to \{{{data}}} in template file
|
||||||
array('data' => 'foo'),
|
|
||||||
'\\\\foo'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'\{{{data}}}',
|
|
||||||
array('data' => 'foo'),
|
array('data' => 'foo'),
|
||||||
'{{{data}}}'
|
'{{{data}}}'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'\pi',
|
'\pi', // is equal to \pi in template
|
||||||
array(),
|
array(),
|
||||||
'\pi'
|
'\pi'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'\\\\\\\\qux',
|
'\\\\foo', // is equal to \\foo in template
|
||||||
|
array(),
|
||||||
|
'\\\\foo'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'\\\\\\bar', // is equal to \\\bar in template
|
||||||
|
array(),
|
||||||
|
'\\\\\\bar'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'\\\\\\\\qux', // is equal to \\\\qux in template file
|
||||||
array(),
|
array(),
|
||||||
'\\\\\\\\qux'
|
'\\\\\\\\qux'
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user