Template directive: if

The directive @if(): is part of the conditional operator directives. It is being used optionally along with @else() and @elseif() operators. The @if(): marks the opening of the condition while it is also terminally ended by the @endif; closing operator. The sample below shows how to apply this directive
if
Example: conditional if
  <?php 
  
  namespace spoova\mi\windows\Routes;
  
  use Route;
  
  class Home extends Route {
  
     function __construct() {
    
        self::call($this, [
        
           // declare accepted urls
           lastUrl() => 'home';
           
           // parse variable arguments
           SELF::ARGS => [
            'var' => 'foo'
           ] 

        ]);
     
     } 
     
     function home($args) {
       
       self::load('home' => compile($args));
       
     }
  
  } 
                
In the compiled template file, we can test for the parsed variables using the if condition. This is shown below
   @if($var === 'foo'): 
   
     This is {{ $var }}
     
   @elseif($var === 'bar'):
   
     This is {{ $var }}
     
   @else:
   
     The value of $var is not defined. 
     
   @endif;
                
The response returned above will be
   This is foo