Skip to content

Latest commit

 

History

History
89 lines (60 loc) · 2.23 KB

README.md

File metadata and controls

89 lines (60 loc) · 2.23 KB

This is a Markdown custom template renderer for FluentEmail
It utilises the ITemplateRenderer interface exposed by FluentEmail to hook in custom template renderers

Markdown rendering is provided by the Markdown Razor view engine that is built into ServiceStack and supports full model binding as available in the default Razor renderer.

Installation

Available on NuGet:

PM> Install-Package FluentEmail.Markdown

Example Usage

var email = Email
    .From("[email protected]")
    .To("[email protected]")
    .Subject("woo nuget")
    .UsingTemplateEngine(new MarkdownRenderer())   // Hook in this renderer -- IMPORTANT!!: This needs be set before the next line below
    .UsingTemplateFromFile(@"~/test.md", new { Name = "John Smith", Numbers = new string[] { "1", "2", "3" } });


// You can also set the default renderer so all Email instances will use this renderer by doing the following:

// Set global renderer to use (usually in App init):
Email.DefaultRenderer = new MarkdownRenderer();

// Use FluentEmail without the need to call UsingTemplateEngine() each time
var email = Email
    .From("[email protected]")
    .To("[email protected]")
    .Subject("woo nuget")
    .UsingTemplateFromFile(@"~/test.md", new { Name = "John Smith", Numbers = new string[] { "1", "2", "3" } });

test.md:

# Heading 1

This is a [Markdown](http://mouapp.com) page

1. one
2. two
3. three

You can also bind to Model

Name: @Model.Name

Numbers:

@foreach i in Model.Numbers {
- Number: @i 
}

The current date is: @DateTime.Now

This will be the rendered output (the Message.Body):

<h1>Heading 1</h1>

<p>This is a <a href="http://mouapp.com">Markdown</a> page</p>

<ol>
<li>one</li>
<li>two</li>
<li>three</li>
</ol>

<p>You can also bind to Model</p>

<p>Name: John Smith</p>

<p>Numbers:</p>

<ul>
<li>Number: 1 </li>
<li>Number: 2 </li>
<li>Number: 3 </li>
</ul>

<p>The current date is: 04/10/2012 10:52:33 PM</p>