mirror of
https://github.com/Mibew/handlebars.php.git
synced 2024-11-15 08:44:12 +03:00
Merge pull request #15 from daviddeutsch/master
Support for context passed into a partial as an argument
This commit is contained in:
commit
8eb732f407
@ -314,6 +314,11 @@ class Handlebars_Template
|
||||
private function _partial($context, $current)
|
||||
{
|
||||
$partial = $this->handlebars->loadPartial($current[Handlebars_Tokenizer::NAME]);
|
||||
|
||||
if ( $current[Handlebars_Tokenizer::ARGS] ) {
|
||||
$context = $context->get($current[Handlebars_Tokenizer::ARGS]);
|
||||
}
|
||||
|
||||
return $partial->render($context);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,12 @@ class Handlebars_Tokenizer
|
||||
default:
|
||||
if ($this->tagChange($this->ctag, $text, $i)) {
|
||||
// Sections (Helpers) can accept parameters
|
||||
if ($this->tagType == self::T_SECTION) {
|
||||
// Same thing for Partials (little known fact)
|
||||
if (
|
||||
($this->tagType == self::T_SECTION)
|
||||
|| ($this->tagType == self::T_PARTIAL)
|
||||
|| ($this->tagType == self::T_PARTIAL_2)
|
||||
) {
|
||||
$newBuffer = explode(' ', trim($this->buffer), 2);
|
||||
$args = '';
|
||||
if (count($newBuffer) == 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user