public async Task <string> RenderAsync(IReportingModel model, string htmlSource) { htmlSource = ResolveCSSLinks(htmlSource); htmlSource = ResolveJsLinks(htmlSource); htmlSource = ResolveImageTag(htmlSource); var result = PreMailer.Net.PreMailer.MoveCssInline(htmlSource); return(await Task.FromResult(result.Html)); }
private string ReplaceHeaderFooter(IReportingModel model, string template) { if (!string.IsNullOrEmpty(model.Header)) { template = template.Replace("_HEADER_", model.Header); } if (!string.IsNullOrEmpty(model.Footer)) { template = template.Replace("_FOOTER_", model.Footer); } return(template); }
public async Task <string> RenderAsync(IReportingModel model, string template) { try { template = ReplaceHeaderFooter(model, template); if (FluidTemplate.TryParse(template, out var templateResult)) { var context = new TemplateContext(); context.MemberAccessStrategy.Register(model.Data.GetType()); context.SetValue(_MODEL_, model.Data); return(await templateResult.RenderAsync(context)); } } catch (Exception ex) { _logger.LogError("Error html parser", ex); } return(string.Empty); }