I have a big problem and I don't understand how to solve this. So I have a class for helper :
class IfCondHelper implements HelperInterface
{
public function execute(Template $template, HandlebarsContent $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (count($parsed_args) != 3) {
throw new \InvalidArgumentException(
'"IfCond" helper expects exactly three arguments.'
);
}
switch ($context->get($parsed_args[1])) {
case "==":
return ($context->get($parsed_args[0]) == $context->get($parsed_args[2])) ? $source : false;
break;
..............
}
}
Now in my template I do :
{{#ifCond 2 '==' 2}} {{data.oUser.number}} {{/ifCond}}
The problem is that the template doesn't show the value of data.oUser.number
whitch is 4 but show the code data.oUser.number
whitout interprete them. The helper works fine, because if I do :
{{#ifCond 2 '==' 2}} <p>Test</p> {{/ifCond}}
This works fine. Can you help me please ? Thx in advance and sorry for my english
I found the error, need to do a supplimentaire render after call the helper
return ($context->get($parsed_args[0]) == $context->get($parsed_args[2])) ? $template->render($context) : false;