String Templatization Engine for .Net

I’ve hit the need to be able to store templatized content separately from the code that generates the dynamic fields that fill that content (think mail merge in word). The use case generally revolves around the fact that I want to write code that can send out some type of dynamic content (often an email) which I want to allow my users to customize without changing any code.

For example, we send emails to our clients. We end up tweaking the emails that go out and adding dynamic content (i.e. for example we may want to say “Dear {Contact.FirstName},”). It’s convenient to throw the format of these emails into the database or some XML file and write the code that gives it the values of all the properties separately. So create an Email.XML with the content and an engine that takes that XML file passes it the Contact object and returns the HTML of the email. Conceptually this fairly similar to the goal of separating the view layer in the MVC pattern (the email is the view in this case, the engine is the controller and the Contact object is the model).

It looks like there’s two contenders in the .Net space (both ports of java) (there’s more here but they are fairly niche players).

Has anyone used either of these or other templatization engines? Are the key differences between them I should take into consideration when choosing


I've used StringTemplate.NET and enjoyed the experience. It took a little while to adjust to their world view - things like looping seems cryptic at first. Not allowing templates to call into code kind of goes against the grain of most of the other templating libraries around. But once you get used to it, their decisions make sense and feel natural.

I just used RegEx.Replace and for each match I found between the { and } I looked up the tag in a Dictionary<,> and executed the ITagParser.

Dear {Salutation} {FamilyName}

The current date is {Now=yyyy-MM-dd}

Where the = is an optional format.

It was too little work to justify a 3rd party library.

Need Your Help

Invalid Certificate

php web certificate hosting ssl-certificate

I am trying to solve a problem on my site. Some pages are displayed without any problem by Firefox but other browsers like Chrome, Safari or IE display an Invalid Certificate/Website not trusted er...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.