• Similar to template but the built template is also 'promise-aware' and will allow them to resolve to string values before interpolating them.

    Parameters

    • templateStr: string

      the template string

    • Optional argNames: string[]

      The names of the parameters of the returned function (which can be 'seen' inside the template string). Defaults to: ['arg'].

    • Optional tagName: string

      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 ((...args) => Promise<string>)

      • (...args): Promise<string>
      • Parameters

        • Rest ...args: any[]

        Returns Promise<string>

    Example

    import { asyncTemplate } from 'deleight/template';
    const promise = Promise.resolve("async thing");
    const template = asyncTemplate('I will wait for this ${arg}!!!');
    const t = await template(promise);
    // t === 'I will wait for this async thing!!!'