Skip to content

Commit

Permalink
Update mjml.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Sep 4, 2023
1 parent dbbe3dd commit 192809f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="OpenNotifications" Version="0.2.0" />
<PackageReference Include="OpenNotifications" Version="0.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public ValueTask<EmailTemplate> ParseAsync(EmailTemplate input, bool strict,
throw new EmailFormattingException(context.Errors);
}

if (!string.IsNullOrWhiteSpace(input.BodyHtml))
{
input = input with
{
BodyHtml = MjmlRenderer.FixXML(input.BodyHtml)
};
}

return new ValueTask<EmailTemplate>(input);
}

Expand Down Expand Up @@ -149,7 +141,7 @@ private static EmailMessage Format(EmailTemplate template, EmailContext context,

context.ValidateTemplate(result, EmailTemplateType.BodyHtml);

var (rendered, errors) = MjmlRenderer.Render(result, strict, true);
var (rendered, errors) = MjmlRenderer.Render(result, strict);

foreach (var error in errors.OrEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ internal static class MjmlRenderer

private static readonly IMjmlRenderer Renderer = new Mjml.Net.MjmlRenderer();

public static string FixXML(string mjml)
{
return Renderer.FixXML(mjml, OptionsStrict);
}

public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, bool strict, bool fix)
public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, bool strict)
{
if (string.IsNullOrWhiteSpace(mjml))
{
Expand All @@ -49,11 +44,6 @@ public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, b
{
var options = strict ? OptionsStrict : OptionsOptimized;

if (fix)
{
mjml = Renderer.FixXML(mjml, options);
}

(rendered, var mjmlErrors) = Renderer.Render(mjml, options);

errors = mjmlErrors?.Select(x => new TemplateError(x.Error, x.Line ?? -1, x.Column ?? -1)).ToList();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo.Domain/Notifo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Mjml.Net" Version="1.24.0" />
<PackageReference Include="Mjml.Net" Version="2.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
Expand Down

0 comments on commit 192809f

Please sign in to comment.