import { STRING_TEMPLATE_VARIABLE_REGEX } from "./STRING_TEMPLATE_VARIABLE_REGEX.js";

/**
 *
 * @param {string} template
 * @param {object} seed
 * @returns {string}
 */
export function seedVariablesIntoTemplateString(template, seed) {

    const result = template.replace(STRING_TEMPLATE_VARIABLE_REGEX, function (match, varName) {
        const value = seed[varName];

        if (value === undefined) {
            console.error(`No value provided for variable '${varName}' in template '${template}', seed:`, seed);
        }

        return value;
    });

    return result;
}
