Template directive: Script

This is used to pull the contents of an external javascript template file into a main PHP template file. It works similarly as the @style() directive used for css. The javascript template file is structured to contain multiple divisions of javascript codes which can be pulled using the @script() template directive.
script
Example: Javascript Rex File (index.rex.js)
  
  #script:js1
    
    function hi(){
      console.log('hi')
    }
    
  #script;

  #script:js2
    
    hi();
    
  #script;
  
                  
Now, we can import our javascript codes into php templates using the division id.
  @script('index:js1')  returns code in js1 above 
  @script('index:js2')  returns code in js2 above 
  
  We can also import both js at once

  @style('index:js1:js2')  returns code in js1 & js2 above 
                  
In the example above, the contents of the rex javascript template file can be imported into any template file just as shown above. It is important not to store heavy javascript files into the javascript rex template file as this may break the application. Developers should organize and simplify their codes into different files which can then be imported by the @script() directive. Every rex file must also be located within the rex directory or subdirectory folders as this is the location the application will start searching for files from. In situtation where our index.rex.js file is in windows/Rex/js directory for example, then the path can be resolved by using dots as shown below
  @style('js.index:css1:css2')