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

Execute process or processes.

tplEngine.run ( process, data, hooks )

  • process: string | string[]. Process name/names for execution;
  • data: any;
  • hooks ?: hookFunctions{}. Find detailed information in process-step 'hook' documentation
  • Method return options:
    • result: string[];
    • error: string[];
  • Method is not chainable;

Example:

const
         tplEngine   = new CodeAssemblyLine()
       , simple = 'Some text with {{place}}.'
       , complex  = '{{place}}: {{text}}'
       , processTest =  [ 
                             { do: 'draw', tpl: 'simple', as: 'text' }   // enrich existing data. Set render result as property 'text'
                           , { do: 'draw', tpl: 'complex'  }
                           , { do: 'block', name: 'result' }   // Save results in block 'result' 
                        ]                                                       
        , renderData  = { place: 'test string'}
        ;
        
 tplEngine.insertProcess ( processTest, 'test')
 tplEngine.insertTemplate ( {simple, complex} )
        
        
        
 tplEngine.run ( 'test', renderData )
 const result = tplEngine.getBlock ( 'result' )
 // -> 'test string: Some text with test string.'

 

Runkit: playground available