mirror of
https://github.com/Mibew/handlebars.php.git
synced 2024-11-15 08:44:12 +03:00
Merge pull request #127 from thormeier/partial-support-and-error-reporting
Fix handling of named arguments in partials
This commit is contained in:
commit
10dbe6442e
@ -538,7 +538,12 @@ class Template
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($positionalArgs, $arguments->getNamedArguments());
|
||||
$namedArguments = array();
|
||||
foreach ($arguments->getNamedArguments() as $key => $value) {
|
||||
$namedArguments[$key] = $context->get($value);
|
||||
}
|
||||
|
||||
return array_merge($positionalArgs, $namedArguments);
|
||||
}
|
||||
|
||||
|
||||
|
@ -722,6 +722,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');
|
||||
@ -730,9 +735,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