Function template

template is used to replace data by name in template strings. The default expression looks for {{name}} to identify names.

Ex. template('Hello, {{name}}', { name: 'ray' })
Ex. template('Hello, <name>', { name: 'ray' }, /<(.+?)>/g)
  • Parameters

    • str: string
    • data: Record<string, any>
    • regex: RegExp = ...

    Returns string