mirror of
				https://github.com/Mibew/handlebars.php.git
				synced 2025-11-04 04:05:07 +03:00 
			
		
		
		
	Fix handling of named arguments in partials
Also fix tests that weren't even executed
This commit is contained in:
		
							parent
							
								
									6ef6b7bc08
								
							
						
					
					
						commit
						2e1b67208d
					
				@ -538,7 +538,16 @@ class Template
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return array_merge($positionalArgs, $arguments->getNamedArguments());
 | 
			
		||||
        $namedArguments = array();
 | 
			
		||||
        foreach ($arguments->getNamedArguments() as $key => $value) {
 | 
			
		||||
            if (false === $value instanceof String) {
 | 
			
		||||
                $value = $context->get($value);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $namedArguments[$key] = $value;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return array_merge($positionalArgs, $namedArguments);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -729,6 +729,11 @@ EOM;
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('foobar', $engine->render("{{>presetVariables myVar='foobar'}}", array()));
 | 
			
		||||
        $this->assertEquals('foobar=barbaz', $engine->render("{{>presetVariables myVar='foobar=barbaz'}}", array()));
 | 
			
		||||
        $this->assertEquals('qux', $engine->render("{{>presetVariables myVar=foo}}", array('foo' => 'qux')));
 | 
			
		||||
        $this->assertEquals('qux', $engine->render("{{>presetVariables myVar=foo.bar}}", array('foo' => array('bar' => 'qux'))));
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('HELLO', $engine->render('{{>test parameter}}', array('parameter' => array('key' => 'HELLO'))));
 | 
			
		||||
        $this->assertEquals('its foo', $engine->render('{{>foo}}', array()));
 | 
			
		||||
        $engine->registerPartial('foo-again', 'bar');
 | 
			
		||||
@ -737,9 +742,6 @@ EOM;
 | 
			
		||||
 | 
			
		||||
        $this->setExpectedException('RuntimeException');
 | 
			
		||||
        $engine->render('{{>foo-again}}', array());
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals('foobar', $engine->render("{{>presetVariables myVar='foobar'}}", array()));
 | 
			
		||||
        $this->assertEquals('foobar=barbaz', $engine->render("{{>presetVariables myVar='foobar=barbaz'}}", array()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user