Separate stacks are necessary for blocks to be resolved independently of variables. Renamed parent_* to block_*.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
class Mustache_Context
|
||||
{
|
||||
private $stack = array();
|
||||
private $block_stack = array();
|
||||
|
||||
/**
|
||||
* Mustache rendering Context constructor.
|
||||
@@ -38,6 +39,11 @@ class Mustache_Context
|
||||
array_push($this->stack, $value);
|
||||
}
|
||||
|
||||
public function pushBlockContext($value)
|
||||
{
|
||||
array_push($this->block_stack, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the last Context frame from the stack.
|
||||
*
|
||||
@@ -48,6 +54,11 @@ class Mustache_Context
|
||||
return array_pop($this->stack);
|
||||
}
|
||||
|
||||
public function popBlockContext()
|
||||
{
|
||||
return array_pop($this->block_stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last Context frame.
|
||||
*
|
||||
@@ -120,9 +131,9 @@ class Mustache_Context
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function findFromParent($id)
|
||||
public function findInBlock($id)
|
||||
{
|
||||
foreach($this->stack as $context) {
|
||||
foreach($this->block_stack as $context) {
|
||||
if (is_array($context) && array_key_exists($id, $context)) {
|
||||
return $context[$id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user