|
|
|
|
@ -4,4 +4,13 @@ const renderVariables = (template, data) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { renderVariables }
|
|
|
|
|
const renderConditionals = (template, data) => {
|
|
|
|
|
return template.replace(/\{\{#if (\w+)\}\}([\s\S]*?)\{\{#endif\}\}/g, (match, condition, innerTemplate) => {
|
|
|
|
|
if(eval(condition)){
|
|
|
|
|
return innerTemplate
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
export { renderVariables, renderConditionals }
|
|
|
|
|
|