Whoops. Missed some docs and cleanup :)
This commit is contained in:
@@ -334,10 +334,11 @@ class Mustache_Compiler
|
|||||||
* @param string $otag Current Mustache opening tag
|
* @param string $otag Current Mustache opening tag
|
||||||
* @param string $ctag Current Mustache closing tag
|
* @param string $ctag Current Mustache closing tag
|
||||||
* @param int $level
|
* @param int $level
|
||||||
|
* @param bool $arg (default: false)
|
||||||
*
|
*
|
||||||
* @return string Generated section PHP source code
|
* @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 = '';
|
$filters = '';
|
||||||
|
|
||||||
@@ -354,7 +355,7 @@ class Mustache_Compiler
|
|||||||
$delims = '';
|
$delims = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = ucfirst(md5($delims."\n".$source));
|
$key = ucfirst(md5($delims."\n".$source));
|
||||||
|
|
||||||
if (!isset($this->sections[$key])) {
|
if (!isset($this->sections[$key])) {
|
||||||
$this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2));
|
$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) {
|
if ($arg === true) {
|
||||||
return $key;
|
return $key;
|
||||||
} else {
|
} else {
|
||||||
$method = $this->getFindMethod($id);
|
$method = $this->getFindMethod($id);
|
||||||
$id = var_export($id, true);
|
$id = var_export($id, true);
|
||||||
|
|
||||||
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
|
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
class Mustache_Context
|
class Mustache_Context
|
||||||
{
|
{
|
||||||
private $stack = array();
|
private $stack = array();
|
||||||
private $block_stack = array();
|
private $blockStack = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustache rendering Context constructor.
|
* Mustache rendering Context constructor.
|
||||||
@@ -39,9 +39,14 @@ class Mustache_Context
|
|||||||
array_push($this->stack, $value);
|
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)
|
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);
|
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()
|
public function popBlockContext()
|
||||||
{
|
{
|
||||||
return array_pop($this->block_stack);
|
return array_pop($this->blockStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,9 +141,16 @@ class Mustache_Context
|
|||||||
return $value;
|
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)
|
public function findInBlock($id)
|
||||||
{
|
{
|
||||||
foreach ($this->block_stack as $context) {
|
foreach ($this->blockStack as $context) {
|
||||||
if (array_key_exists($id, $context)) {
|
if (array_key_exists($id, $context)) {
|
||||||
return $context[$id];
|
return $context[$id];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user