Exemple #1
0
        private async Task <string> RenderAsync(MailTemplate template, MailTemplateContext context)
        {
            using (var output = new StringWriter())
            {
                template.Context = context;
                template.Output  = output;

                await template.ExecuteAsync();

                await output.FlushAsync();

                template.Output = null;

                string result;
                if (template.Layout != null)
                {
                    result = await RenderLayoutAsync(template.Layout, context, output.ToString(), template.Sections);
                }
                else
                {
                    result = output.ToString();
                }

                return(result);
            }
        }