High performance, light & extensible template engine library for .NET 4.7.2 and above.
$ dotnet add package CottleCottle is an open-source (MIT) templating engine for C# .NET designed to be light (no external dependency & simple API), fast (see benchmark) and extensible (see advanced features).
Hello, {name}!
{if len(messages) > 0:
You have {len(messages)} new message{if len(messages) > 1:s} in your mailbox!
|else:
You have no new message.
}
var document = Document.CreateDefault(template).DocumentOrThrow;
return document.Render(Context.CreateBuiltin(new Dictionary<Value, Value>
{
["messages"] = GetMessages(),
["name"] = "JC Denton"
}));