calderawphelpersis

Class is.

Defined (1)

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

/vendor/calderawp/wp-handlebars-helpers/src/is.php  
  1. class is { 
  2. /** 
  3. * Execute the is Helper for Handlebars.php {{#is variable value}} code {{else}} alt code {{/is}} 
  4. * based off the IfHelper 
  5. * @param \Handlebars\Template $template The template instance 
  6. * @param \Handlebars\Context $context The current context 
  7. * @param array $args The arguments passed the the helper 
  8. * @param string $source The source 
  9. * @return mixed 
  10. */ 
  11. public static function helper( $template, $context, $args, $source ) { 
  12.  
  13. $parts = explode(' ', $args); 
  14. $args = $parts[0]; 
  15. $value = $parts[1]; 
  16.  
  17. if (is_numeric($args)) { 
  18. $tmp = $args; 
  19. } else { 
  20. $tmp = $context->get($args); 
  21.  
  22. $context->push($context->last()); 
  23. if ($tmp === $value) { 
  24. $template->setStopToken('else'); 
  25. $buffer = $template->render($context); 
  26. $template->setStopToken(false); 
  27. $template->discard($context); 
  28. } else { 
  29. $template->setStopToken('else'); 
  30. $template->discard($context); 
  31. $template->setStopToken(false); 
  32. $buffer = $template->render($context); 
  33. $context->pop(); 
  34.  
  35. return $buffer; 
  36.  
  37.