Whoops. Missed some docs and cleanup :)

This commit is contained in:
Justin Hileman
2014-06-27 00:18:41 -07:00
parent 349b58b8ca
commit 1fe5b0dfc2
2 changed files with 27 additions and 9 deletions
+5 -4
View File
@@ -334,10 +334,11 @@ class Mustache_Compiler
* @param string $otag Current Mustache opening tag
* @param string $ctag Current Mustache closing tag
* @param int $level
* @param bool $arg (default: false)
*
* @return string Generated section PHP source code
*/
private function section($nodes, $id, $start, $end, $otag, $ctag, $level, $arg=false)
private function section($nodes, $id, $start, $end, $otag, $ctag, $level, $arg = false)
{
$filters = '';
@@ -354,7 +355,7 @@ class Mustache_Compiler
$delims = '';
}
$key = ucfirst(md5($delims."\n".$source));
$key = ucfirst(md5($delims."\n".$source));
if (!isset($this->sections[$key])) {
$this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2));
@@ -363,8 +364,8 @@ class Mustache_Compiler
if ($arg === true) {
return $key;
} else {
$method = $this->getFindMethod($id);
$id = var_export($id, true);
$method = $this->getFindMethod($id);
$id = var_export($id, true);
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
}
+22 -5
View File
@@ -14,8 +14,8 @@
*/
class Mustache_Context
{
private $stack = array();
private $block_stack = array();
private $stack = array();
private $blockStack = array();
/**
* Mustache rendering Context constructor.
@@ -39,9 +39,14 @@ class Mustache_Context
array_push($this->stack, $value);
}
/**
* Push a new Context frame onto the block context stack.
*
* @param mixed $value Object or array to use for block context
*/
public function pushBlockContext($value)
{
array_push($this->block_stack, $value);
array_push($this->blockStack, $value);
}
/**
@@ -54,9 +59,14 @@ class Mustache_Context
return array_pop($this->stack);
}
/**
* Pop the last block Context frame from the stack.
*
* @return mixed Last block Context frame (object or array)
*/
public function popBlockContext()
{
return array_pop($this->block_stack);
return array_pop($this->blockStack);
}
/**
@@ -131,9 +141,16 @@ class Mustache_Context
return $value;
}
/**
* Find an argument in the block context stack.
*
* @param string $id
*
* @return mixed Variable value, or '' if not found.
*/
public function findInBlock($id)
{
foreach ($this->block_stack as $context) {
foreach ($this->blockStack as $context) {
if (array_key_exists($id, $context)) {
return $context[$id];
}