Template directive: flash

The @flash() is a shorthand directive for Res::flash(); method. When a flash notification message is set, this directive makes it easier to fetch the flash message once before it is finally removed. Every notification message is defined by its unique notification key that is used to access the message.
flash
Example: A PHP File
  <php? 
 
  namespace spoova\mi\windows\Routes
  use Window;
 
  class Home extends Window {
  
      function __construct() {
      
        if($logged_in) {
        
          // $logged_in as some incoming database response    
        
          Res::setFlash('account', 'user logged in');
          
          header('location:'.domurl('dashboard'));
          
        } 
        
        self::call($this, [lastUrl() => 'home']);
        
      } 
      
      function home() {
      
         self::load('home', fn() => compile ()) ;
      
      } 
  
  }
  
                  
From the sample route above, we defined a flash message with its unique id account in the Home route. Assuming we have another route Dashboard that renders a dashboard.rex.php template file, when the user logs in, the redirection is made from Home to Dashboard route which renders a dashboard.rex.php template file. From the template file, we can apply the directive as shown below:
  <div>  
  
  @flash('account')
  
  </div>
                  
From the above, once the user logs in, the message will be saved only to be displayed on the web page once from the other dashboard web page just as shown below:
  <div>  
  
  user logged in
  
  </div>
                  
We can also overwrite the default message by supplying a second argument which will only be displayed if the unique id's returned value is not empty.
  <div>  
  
  @flash('account', 'custom message here')
  
  </div>
                  
From the above, the custom message will be displayed if the default message is not empty. The flash notification messages is handled by the Notice class.