mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-29 10:19:11 +00:00
19 lines
378 B
JavaScript
19 lines
378 B
JavaScript
'use strict';
|
|
|
|
module.exports = function (template, args) {
|
|
if (!args) {
|
|
return interpolate.bind(null, template);
|
|
}
|
|
|
|
return interpolate(template, args);
|
|
};
|
|
|
|
function interpolate(template, args) {
|
|
if (typeof args === 'undefined') {
|
|
args = {};
|
|
}
|
|
return template.replace(/{([^}]*)}/g, function (match, key) {
|
|
return key in args ? args[key] : match;
|
|
});
|
|
}
|