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

    • argNames: string[]

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

    • 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) => string)

      • (...any): string
      • Parameters

        • Rest ...any: any

        Returns string

    Example

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