.getTemplate - PeterNaydenov/code-assembly-line GitHub Wiki

Exports template/templates as an externalTemplate object.

tplEngine.getTemplate ( tplName )

  • tplName: string | string[]. Count template names for export;
  • Method return options:
    • template: externalTemplate. ;
  • Method is not chainable;

Example:

  const templates = {
                        'hello' : 'Hello {{user}}'             // template 'hello'
                      , 'bye'   : 'Good bye {{user}}'          // template 'bye'
                      , 'tnx'   : 'Special thanks to {{user}}'  // template 'tnx'
                    }

 tplEngine.insertTemplate ( templates )
 // Now templates are available in template engine

 tplEngine.getTemplate ( 'bye' )
 // ->  { bye : 'Good bye {{user}}' }

 tplEngine.getTemplate ( ['bye','tnx'] )
 /*
    ->   {
             'bye' : 'Good bye {{user}}'
           , 'tnx' : 'Special thanks to {{user}}'
         }
 */  

 // Simplified version for getting multiple templates.
 tplEngine.getTemplate ( 'bye', 'tnx' )
 /*
    ->   {
             'bye' : 'Good bye {{user}}'
           , 'tnx' : 'Special thanks to {{user}}'
         }
 */