HandlebarsHelperIfHelper

Handlebars halper interface.

Defined (2)

The class is defined in the following location(s).

/vendor/calderawp/metaplate-core/vendor/xamin/handlebars.php/src/Handlebars/Helper/IfHelper.php  
  1. class IfHelper implements Helper 
  2. /** 
  3. * Execute the helper 
  4. * @param \Handlebars\Template $template The template instance 
  5. * @param \Handlebars\Context $context The current context 
  6. * @param array $args The arguments passed the the helper 
  7. * @param string $source The source 
  8. * @return mixed 
  9. */ 
  10. public function execute(Template $template, Context $context, $args, $source) 
  11. if (is_numeric($args)) { 
  12. $tmp = $args; 
  13. } else { 
  14. $tmp = $context->get($args); 
  15.  
  16. $context->push($context->last()); 
  17. if ($tmp) { 
  18. $template->setStopToken('else'); 
  19. $buffer = $template->render($context); 
  20. $template->setStopToken(false); 
  21. $template->discard($context); 
  22. } else { 
  23. $template->setStopToken('else'); 
  24. $template->discard($context); 
  25. $template->setStopToken(false); 
  26. $buffer = $template->render($context); 
  27. $context->pop(); 
  28.  
  29. return $buffer; 
/vendor/xamin/handlebars.php/src/Handlebars/Helper/IfHelper.php  
  1. class IfHelper implements Helper 
  2. /** 
  3. * Execute the helper 
  4. * @param \Handlebars\Template $template The template instance 
  5. * @param \Handlebars\Context $context The current context 
  6. * @param array $args The arguments passed the the helper 
  7. * @param string $source The source 
  8. * @return mixed 
  9. */ 
  10. public function execute(Template $template, Context $context, $args, $source) 
  11. $parsedArgs = $template->parseArguments($args); 
  12. $tmp = $context->get($parsedArgs[0]); 
  13.  
  14. $context->push($context->last()); 
  15. if ($tmp) { 
  16. $template->setStopToken('else'); 
  17. $buffer = $template->render($context); 
  18. $template->setStopToken(false); 
  19. $template->discard($context); 
  20. } else { 
  21. $template->setStopToken('else'); 
  22. $template->discard($context); 
  23. $template->setStopToken(false); 
  24. $buffer = $template->render($context); 
  25. $context->pop(); 
  26.  
  27. return $buffer;