Skip to content

r3c/cottle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cottle: Compact Object to Text Transform Language

Build Status NuGet license

Overview

Cottle 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).

Sample

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"
}));

Resource