const obj = {className: 'test'}
let str = `<ul class="{{ className }}"</ul>`
for (let key in obj ) {
str.replace(`/${key}/g`, obj[key];
}
const expression = /{{\s+?(\w+)\s+?}}/g;
const pasteParams = (string, params) => {
return string.replace(expression, (match, key) => key in params
? params[key]
: key
);
};
pasteParams('<ul class="{{ className }}"></ul>', {
className: 'my-class'
});