20 lines
585 B
JavaScript
20 lines
585 B
JavaScript
function interpolateConciergeGreeting(template, values = {}) {
|
|
const greeting = String(template || '').trim();
|
|
if (!greeting) {
|
|
const profileName = values.profileName || 'Guest';
|
|
const eventName = values.eventName ? ` for ${values.eventName}` : '';
|
|
return `Hello ${profileName}${eventName}! How can I help you today?`;
|
|
}
|
|
|
|
return greeting.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
|
|
if (Object.prototype.hasOwnProperty.call(values, key)) {
|
|
return String(values[key] ?? '');
|
|
}
|
|
return '';
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
interpolateConciergeGreeting,
|
|
};
|