Monday, June 13, 2011

Using the nustache template engine.

Nustache is Mustache for .net. Get it from https://github.com/jdiamond/Nustache

Here is a basic example in c#.
string sTemplate = "* {{greeting}} {{subject}}!";
Dictionary<string, string> testData = new Dictionary<string,string>();
testData["greeting"] = "Hello";
testData["subject"] = "world";
Console.Out.WriteLine(Nustache.Core.Render.StringToString(sTemplate, testData));
The Render class has different methods for different inputs and outputs, such as FileToFile and FileToString.

This is the output produced:
* Hello world!