Suppress else when rendering empty block defaults.
This commit is contained in:
@@ -240,10 +240,11 @@ class Mustache_Compiler
|
||||
$blockFunction = $context->findInBlock(%s);
|
||||
if (is_callable($blockFunction)) {
|
||||
$buffer .= call_user_func($blockFunction, $context);
|
||||
} else {%s
|
||||
}
|
||||
%s}
|
||||
';
|
||||
|
||||
const BLOCK_VAR_ELSE = '} else {%s';
|
||||
|
||||
/**
|
||||
* Generate Mustache Template inheritance block variable PHP source.
|
||||
*
|
||||
@@ -261,7 +262,12 @@ class Mustache_Compiler
|
||||
{
|
||||
$id = var_export($id, true);
|
||||
|
||||
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, $level));
|
||||
$else = $this->walk($nodes, $level);
|
||||
if ($else !== '') {
|
||||
$else = sprintf($this->prepare(self::BLOCK_VAR_ELSE, $level + 1, false, true), $else);
|
||||
}
|
||||
|
||||
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $else);
|
||||
}
|
||||
|
||||
const BLOCK_ARG = '$blocksContext[%s] = array($this, \'block%s\');';
|
||||
|
||||
Reference in New Issue
Block a user