Skip to main content

template

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

API

function template(str: string, data: Record<string, any>, regex?: RegExp): string;

Usage

import { titleCase } from '@feedzai/js-utilities';

template('Hello, {{name}}', { name: 'ray' })
//-> Hello, ray

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