public void Error_On_Invalid_Mjml() { var renderer = new MjmlRenderer(nodePath); var rendered = renderer.Render("foo"); Assert.IsFalse(rendered.Success, "Rendering invalid MJML should fail, instead got: " + rendered.Result); Assert.IsFalse(string.IsNullOrWhiteSpace(rendered.Result), "Result should explain the cause of the failure."); }
public void Render_Mjml_To_Html() { var renderer = new MjmlRenderer(nodePath); var rendered = renderer.Render(@" <mjml> <mj-body> <mj-section> <mj-column> <mj-text>Hello World</mj-text> </mj-column> </mj-section> </mj-body> </mjml>"); Assert.IsTrue(rendered.Success, "Markup should render successfully, instead got error: " + rendered.Result); Assert.IsTrue(rendered.Result.Contains("Hello World"), "Result should contain rendered text."); }
static void Main() { var renderer = new MjmlRenderer(@"C:\Program Files\nodejs\node.exe"); var mjmlTemplate = File.ReadAllText("example.mjml"); var rendered = renderer.Render(mjmlTemplate); if (rendered.Success) { File.WriteAllText("output.html", rendered.Result); Process.Start(new ProcessStartInfo() { FileName = "output.html", UseShellExecute = true }); } else { Console.Error.WriteLine(rendered.Result); Environment.Exit(1); } }