- saving progress;

This commit is contained in:
Vitalii Kiiko
2025-01-21 11:08:37 +01:00
parent 61763a961b
commit 07cecda529
23 changed files with 915 additions and 62 deletions

View File

@@ -0,0 +1,23 @@
import mustache from 'mustache';
import { replace } from 'ramda';
/**
* Use mustachejs to parse content and replace variables with their values
* Each variable (everything in brackets) is expression for EE
*
* @param {string} content
* @param {object} context
*
* @returns {string}
*/
const renderWithDataVars = (content = '', context = {}) => {
try {
let newContent = replace(/{/g, '{{&', content);
newContent = replace(/}/g, '}}', newContent);
return mustache.render(newContent, context);
} catch {
return content;
}
};
export default renderWithDataVars;