• Async equivalent of templates. The async template tag ('T' by default) is applied to the template string. Use this when there are promises among the arguents that will be passed to the returned function.

    Parameters

    • templateStr: string

      The template string

    • argNames: string[] = ...

      The names of the parameters (starting with the iterable) of the returned function (which can be 'seen' inside the template string)

    • itemName: string = 'item'

      The name of the current item of the iterable as seen inside the template string. Defaults to 'item'

    • tagName: string = 'T'

      Supply a tagName argument to change the name of the tag function inside the template string if the default name (T) is present in argNames.

    Returns IAsyncTemplates

    Example

    import { asyncTemplates } from 'deleight/apriori';
    let t = asyncTemplates('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
    console.log(t instanceof Promise); // true
    t = (await Promise.all(t)).join(' ')
    // t === 'I will async render this 1 I will async render this 2 I will async render this 3 I will async render this 4 I will async render this 5'