function template(pattern, data) { return pattern.replace(/\$\{(\w+)\}/g, function (match, prop, offset, string) { return data[prop] ?? '' }) }