Skip to content

srijken/FluentEmail.Markdown

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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("bob@hotmail.com")
    .To("somedude@gmail.com")
    .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("bob@hotmail.com")
    .To("somedude@gmail.com")
    .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>

About

Markdown custom template renderer for FluentEmail

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.3%
  • Shell 2.7%