Introducing DotLiquid: the secure, open-source template engine for .NET

October 26, 2010

Want to skip straight to the goods?

The Problem

One of the questions that comes up fairly often for the average developer is: "How can I transfer this data into that output?" The data often takes the form of an object, and the output is often HTML or plain text. There are, of course, many ways of skinning the cat1.

These existing .NET template engines are very suitable for one specific use-case: when the developer, or another trusted party, is responsible for authoring the templates. However, to the best of my knowledge, there have not been any full-featured2 template engines available for .NET which are suitable for the other use-case: when you want customers to edit their own templates. You may want this because you host the customer's website on your server, or simply because .NET is too complex to give to a non-techie.

Enter DotLiquid

This is the thinking behind why I wrote DotLiquid, a C# port of the Liquid template engine from Ruby. DotLiquid offers the following benefits:

Where can I find it?

The website is here. You can try it online. The source code for DotLiquid is hosted on GitHub, and can be found here. This is also the place to log issues. There is some documentation, although (as ever) I hope to expand on what is there. The current version of DotLiquid can be downloaded here (we're on Beta 2 at the moment, and we're just letting that brew for a while before pushing out the final release of 1.0). Once "the package manager formerly known as NuPack" has settled down a bit, I'll be creating a package so that you can easily include DotLiquid in your projects.

If you've made it this far, chances are you might be looking for this sort of library. If you do use it in your project, I hope you find it helpful, and if you would like your project to be mentioned on the DotLiquid website, just drop me a line.

Acknowledgements

DotLiquid wouldn't exist without Liquid, and Liquid wouldn't exist without Tobias Lütke. Thank you Tobias.

I'd also like to thank Alessandro Petrelli for his many useful contributions to DotLiquid.


  1. I actually like cats. 

  2. I say "full-featured" because I could find at least one template engine which uses Django-style syntax, but I don't think it offers important constructs such as loops and conditionals. 


comments powered by Disqus