В шаблоне Handlebars я использую вложенный оператор if/else, см. шаблон ниже:
Код: Выделить всё
{{#if options.use_title_separator}}
{{#if options.back_to_top}}
{{ options.text_label }}
{{else}}
{{ options.text_label }}
{{/if}}
{{/if}}
Код: Выделить всё
Parse error[/b]: syntax error, unexpected T_FUNCTION in [b]/.../Handlebars/Helpers.php[/b] on line [b]71[/b]
Код: Выделить всё
$this->add(
'if',
function ($template, $context, $args, $source) {
$tmp = $context->get($args);
$buffer = '';
if ($tmp) {
$template->setStopToken('else');
$buffer = $template->render($context);
$template->setStopToken(false);
$template->discard($context);
} else {
$template->setStopToken('else');
$template->discard($context);
$template->setStopToken(false);
$buffer = $template->render($context);
}
return $buffer;
}
);
Можете ли вы помочь мне решить эту проблему?
Спасибо