Add template parsing and execution to mail service.

This commit is contained in:
mikestefanello 2021-12-19 20:37:51 -05:00
parent 15974c9b77
commit 337ebb67b4
4 changed files with 38 additions and 14 deletions

View file

@ -47,9 +47,9 @@ func NewTemplateRenderer(cfg *config.Config) *TemplateRenderer {
func (t *TemplateRenderer) Parse(module, key, name string, files []string, directories []string) error {
cacheKey := t.getCacheKey(module, key)
// Check if the template has not yet been parsed or if the app environment is local, so that templates reflect
// changes without having the restart the server
if _, err := t.Load(module, key); err != nil {
// Check if the template has not yet been parsed or if the app environment is local, so that
// templates reflect changes without having the restart the server
if _, err := t.Load(module, key); err != nil || t.config.App.Environment == config.EnvLocal {
// Initialize the parsed template with the function map
parsed := template.New(name + config.TemplateExt).
Funcs(t.funcMap)