Skip to content

Instantly share code, notes, and snippets.

@pointofpresence
Created December 19, 2022 11:19
Show Gist options
  • Save pointofpresence/419364f64cc223012d28669d01c48127 to your computer and use it in GitHub Desktop.
Save pointofpresence/419364f64cc223012d28669d01c48127 to your computer and use it in GitHub Desktop.
Простой шаблонизатор с трок ES6
/**
* Простой шаблонизатор строк
*/
const formatString = (template, params = {}) => {
const names = Object.keys(params);
const vals = Object.values(params);
return new Function(...names, `return \`${template}\`;`)(...vals);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment