@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 933 B
JavaScript
import{copy as e}from"../../i18n/copy.mjs";import t from"../../../constants/constants.mjs";import{readFile as n}from"node:fs/promises";import r from"node:path";import i from"mustache";const a=async(a,o)=>{let s=a.config.email.templates.rendered;if(s){let t=s[o.template];return t===void 0?{error:{message:e(`server:core.email.templates.not.found.message`),status:404},data:void 0}:{error:void 0,data:i.render(t,o.data)}}try{let s=r.resolve(process.cwd(),a.config.build.paths.outDir,t.email.renderedOutput),c=JSON.parse(await n(s,`utf-8`))[o.template];return c?{error:void 0,data:i.render(c.html,o.data)}:{error:{message:e(`server:core.email.templates.not.found.message`),status:404},data:void 0}}catch(t){return{error:{message:e(`server:core.email.templates.not.found.message`,t instanceof Error?{defaultMessage:t.message}:void 0),status:404},data:void 0}}};export{a as default};
//# sourceMappingURL=render-mustache-template.mjs.map