template
Template a string with values from a data object using a search expression
155 bytes
Usage
Given a string, an object of data, and a format expression to search for, returns a string with all elements that matched the search replaced with their matching value from the data object.
import * as import _
_ from 'radashi'
import _
_.function template(str: string, data: Record<string, any>, regex?: RegExp): stringexport template
Replace data by name in template strings. The default expression
looks for {{name}} to identify names.
template('It is {{color}}', { color: string
color: 'blue' }) // => It is blueimport _
_.function template(str: string, data: Record<string, any>, regex?: RegExp): stringexport template
Replace data by name in template strings. The default expression
looks for {{name}} to identify names.
template('It is <color>', { color: string
color: 'blue' }, /<(.+?)>/g) // => It is blue