mirror of
				https://github.com/Mibew/handlebars.php.git
				synced 2025-11-04 12:05:09 +03:00 
			
		
		
		
	Merge pull request #146 from hfhchan/master
Fix: Don't re-escape variables that are already safe
This commit is contained in:
		
						commit
						1a0d4dc772
					
				@ -629,7 +629,7 @@ class Template
 | 
			
		||||
        if (is_array($value)) {
 | 
			
		||||
            return 'Array';
 | 
			
		||||
        }
 | 
			
		||||
        if ($escaped) {
 | 
			
		||||
        if ($escaped && !($value instanceof SafeString)) {
 | 
			
		||||
            $args = $this->handlebars->getEscapeArgs();
 | 
			
		||||
            array_unshift($args, (string)$value);
 | 
			
		||||
            $value = call_user_func_array(
 | 
			
		||||
 | 
			
		||||
@ -576,6 +576,20 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
 | 
			
		||||
        $this->assertEquals('new', $string->getString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * test SafeString class
 | 
			
		||||
     */
 | 
			
		||||
    public function testSafeStringClass()
 | 
			
		||||
    {
 | 
			
		||||
        $loader = new \Handlebars\Loader\StringLoader();
 | 
			
		||||
        $helpers = new \Handlebars\Helpers();
 | 
			
		||||
        $engine = new \Handlebars\Handlebars(array('loader' => $loader, 'helpers' => $helpers));
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('<strong>Test</strong>', $engine->render('{{string}}', array(
 | 
			
		||||
            'string' => new \Handlebars\SafeString('<strong>Test</strong>')
 | 
			
		||||
        )));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param $dir
 | 
			
		||||
     *
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user