Ok, so it has been a while since I have posted something.
On the project at work we have an internal messaging system. Not the message bus kind of messaging system, but a system that lets our users know about things going on in the system. These messages are displayed inside the application but also can be sent via an email, though there is an option to “opt out” of the email subscription. To that end I have been looking for .NET template engines that allow me to create a “message”, essentially a chunk of html.
There are only 2 constraints I have for the engine.
I have used NVelocity before with a lot of success, but I wanted to see if there where other engines out there, so I spiked RazorEngine, StringTemplate and NVelocity.
Note: These spikes/tests are by no means scientific and are only the output of my own experiences.
Here are the templates used for each engine.
I am going to start with the RazorEngine. We currently have the RazorEngine in the codebase as our template parser and everything was working great, up until we started processing a lot of messages at once. By a lot I am greater an 100, which is no where near the amount we could potentially create in a couple scenarios.
I have never used StringTemplate and found that finding out how to use it was quite a chore. The documentation on the syntax was there but when talking about the port to C# the page is blank. Not deterred, I struggled through it and finally got something up and running. The syntax for the StringTemplate is just NUTS, IMHO. First of all I am looking to generate HTML so having the default delimiters as ‘<’ and ‘>’ is not going to work so I have to change those. While not shown here, I had nothing but problems trying to loop through a list of items.
Finally we have NVelocity. As I mentioned previously, I have past experience with it and am MUCH more comfortable with its syntax than with StringTemplate. I have heard that NVelocity is a dead project, but it looks like it was incorporated into MonoRail and is still available stand alone.
15 seconds for Razor and pretty much negligible for StringTemplate and NVelocity.
Given StringTemplate’s syntax and that I eventually want a “business user”, i.e. not a programmer to create and edit templates, and Razor’s perceived performance issues it looks like we will be making the switch to using NVelocity.
Are there any other templates out there in the .NET space?