Function asyncTemplate

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

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

        • Rest ...any: any

        Returns Promise<string>

    Example

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