Beispiel #1
0
        /// <inheritdoc />
        public async Task <string> GenerateEmailBody <T>(MessageTemplate template, T model)
        {
            template.ThrowIfNull(nameof(template));

            logger.LogInformation($"Start generate email body by template:{template.Name}, model: {model?.ToJson()}, parent template:{template.Parent}");

            var parentTemplate = await GetParentTemplate(template);

            VerifyTemplateAndParentTemplate(template, parentTemplate);

            ITemplateEngine templateEngine = GetTemplateEngine(template.EngineType);

            templateEngine.AddParentTemplate(parentTemplate);

            logger.LogInformation($"Starting async render template with model. Type template engine: {templateEngine.GetType().Name}");

            return(await templateEngine.RenderAsync(template, model));
        }