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

Obtain rendered code snippets.

tplEngine.getBlock ( blockName )

  • blockName: string | string[]. Count block names for export;
  • Method return options:
    • codeSnippet: string. Ready to use code snippet;
  • Method is not chainable;

Example:

  const templates = {
                        'hello' : 'Hello {{user}}'  // template 'hello'
                    }
  const sayHi = [
                     { do: 'set', as: 'user'}
                   , { do: 'draw', tpl: 'hello'}
                   , { do: 'block', name: 'hi' } // save result as block 'hi'
                 ]

 tplEngine
    .insertTemplate ( templates   )
    .insertProcess  ( sayHi, 'hi' )
 // Now template engine is loaded and ready to use



 tplEngine.run ( 'hi', 'Peter' )  // executes process 'hi' and writes block 'hi'
 tplEngine.getBlock ( 'hi' )
 // -> 'Hello Peter'