Skip to content

I am a handle bars like templating engine for .NET

License

Notifications You must be signed in to change notification settings

dburriss/Temptress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Temptress

I am a handle bars like templating engine for .NET.

Temptress uses the {{var}} type syntax for replacing text with values. A big push for this project is that messages are strongly typed and verifiable*(TODO)* against the template.

Requires the reflection helper library Philosphical Monkey.

Basic Usage

Install via Nuget

Install-Package Temptress -Pre

With the following POCO classes defined:

public class WelcomeMessage
{
    public string FullName { get; set; }

    public DateTime JoinDate { get; set; }

    public Address Address { get; set; }
}

public class Address
{
    public int StreetNumber { get; set; }
    public string StreetName { get; set; }
}

Then creating a template:

var template = new Template<WelcomeMessage>("Hello {{FullName}} from {{Address.StreetNumber}} {{Address.StreetName}}!");
var renderer = new TemplateRenderer<WelcomeMessage>(template);

Then you can render the template with whatever data you like, reusing the same template with different data.

Note the creation template is the expensive part (as much as possible) so that the rendering is as fast as possible.

Then rendering the content:

var message = new WelcomeMessage(){ FullName = "Devon", Address = new Address{ StreetNumber = 5, StreetName = "Main"} };
var messageText = renderer.Render(message);

About

I am a handle bars like templating engine for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published