fixes extra escaping of scalar arguments

This commit is contained in:
behrooz shabani (everplays) 2014-06-23 13:29:50 +04:30
parent d92640890f
commit 93b6dd8cb6
2 changed files with 4 additions and 2 deletions

View File

@ -57,6 +57,8 @@ class Tokenizer
const T_UNESCAPED_2 = '&';
const T_TEXT = '_t';
const T_ESCAPE = "\\";
const T_SINGLE_Q = "'";
const T_DOUBLE_Q = "\"";
// Valid token types
private static $_tagTypes = array(
@ -127,7 +129,7 @@ class Tokenizer
$this->escaping = $this->tagChange(self::T_ESCAPE, $text, $i);
if ( $this->escaped and $text[$i] != self::T_UNESCAPED ) {
if ( $this->escaped and !in_array($text[$i], array(self::T_UNESCAPED, self::T_SINGLE_Q, self::T_DOUBLE_Q)) ) {
$this->buffer .= "\\";
}

View File

@ -332,7 +332,7 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
return implode(' ', $parsed_args);
});
$this->assertEquals('a \"b\" c', $engine->render('{{argsTest "a" "\"b\"" \'c\'}}', array()));
$this->assertEquals("a \"b\" c", $engine->render('{{{argsTest "a" "\"b\"" \'c\'}}}', array()));
}
public function testInvalidHelperMustacheStyle()