export function substitute()

in lib/substitute.ts [1:7]


export function substitute(s: string, variables: { [key: string]: string } = { }) {
  // '': '' is an empty substitution
  for (const [key, value] of Object.entries({ ...variables, '': '' })) {
    s = s.replace(new RegExp(`{{ *${escapeRegExp(key)} *}}`, 'g'), value);
  }
  return s;
}