mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-05-02 10:16:41 +03:00
added support for "else" in in if helper. fixes #2
XXX: could it be fixed in better way?
This commit is contained in:
parent
d99f9a7830
commit
600215d648
@ -70,10 +70,15 @@ class Handlebars_Helpers
|
|||||||
'if',
|
'if',
|
||||||
function ($template, $context, $args, $source) {
|
function ($template, $context, $args, $source) {
|
||||||
$tmp = $context->get($args);
|
$tmp = $context->get($args);
|
||||||
|
$parts = explode('{{else}}', $source, 2);
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
if ($tmp) {
|
if ($tmp) {
|
||||||
$buffer = $template->render($context);
|
$buffer = $template->getEngine()->render($parts[0], $context);
|
||||||
}
|
} else {
|
||||||
|
if (isset($parts[1])) {
|
||||||
|
$buffer = $template->getEngine()->render($parts[1], $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user