Skip to content

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 _ from 'radashi'
_.template('It is {{color}}', { color: 'blue' }) // => It is blue
_.template('It is <color>', { color: 'blue' }, /<(.+?)>/g) // => It is blue