示例#1
0
        private static string?RenderTemplate(string template, TemplateContext context,
                                             List <EmailFormattingError> errors, EmailTemplateType type, bool noCache)
        {
            var(fluidTemplate, error) = TemplateCache.Parse(template, noCache);

            if (error != null)
            {
                errors.Add(new EmailFormattingError(error.Message, type, error.Line, error.Column));
            }

            return(fluidTemplate?.Render(context));
        }
示例#2
0
        private static string RenderTemplate(string template, TemplateContext context, bool noCache)
        {
            try
            {
                using (Profiler.TraceMethod <EmailFormatter>())
                {
                    var parsedTemplate = TemplateCache.Parse(template, noCache);

                    return(parsedTemplate.Render(context));
                }
            }
            catch (TemplateParseException ex)
            {
                var errors = ex.Errors.Select(x => new EmailFormattingError(x)).ToList();

                throw new EmailFormattingException(template, errors);
            }
        }