views:

1663

answers:

7

I'm looking for a template engine for .NET/C# to generate email notifications in my application. I read about NVelocity in the past and think it would fit my needs, but it seems this project is dead.

Would you still recommended to use NVelocity for that purpose or can you suggest any alternatives?

Note: I found some other templating engines, but these are mostly "view-engines" for ASP.NET MVC (Brail, NHaml, etc.). But I think these are not what I'm looking for.

+11  A: 

The Castle Project forked the project and have been maintaining it, but they have not put out a release in a while. More details can be found at the Castle Projects NVelocity site. They have also made a number of improvements to it, details of which can be found on their NVelocity improvements page.

If you are looking for an alternative, then I would suggest the upcoming Razor view engine in ASP.Net MVC3 or the Spark View Engine.

Pervez Choudhury
A: 

I would recommend using XSLT for templating. Yes, it requires a little more time to learn the technology, but then you have much more flexible template solution than anything else.

XOR
+3  A: 

You could use brail or nhaml standalone to generate html emails.

The core of nhaml (not sure about brail??) has no references to MVC or ASP.

I have used nhaml to generate XPS documents for printing and reporting from a win forms app.

If it has to be text perhaps http://www.stringtemplate.org/

And here is a similar question http://stackoverflow.com/questions/619923/how-to-use-brail-as-a-stand-alone-general-purpose-templating-engine-like-nveloci

Simon
+1  A: 

You can use the original (and frequently updated) Java version of Velocity in .Net by using IKVM to convert it to an assembly. I have used velocity successfully this way for code generation under .Net. You might also take a look at StringTemplate. There are java and C# versions of StringTemplate. You can find a quick mini-tutorial on using Velocity in .Net here. I suggest taking a hard look at StringTemplate however, as I think it is a cleaner template engine (I'm a recent convert).

Todd Stout
+3  A: 

I don't see a reason not to use NVelocity (the Castle project fork). It's stable and your specific needs (email templates) are probably not as complex as the ones from other projects which use NVelocity, so you shouldn't expect any problems.

Igor Brejc
+2  A: 

There is project on codeplex.

http://www.codeplex.com/NVelocity

Project Description: NVelocity is a port of very propular open source java template enginee framework,velocity 1.6. NVelocity is a pure .Net library written in C# which currently targets Framework version 3.5.

The initial source code checked-in appears to be straight from svn.castleproject.org.

The person who create the CodePlex project (username: TerryLiang) also created one back in August from nLucene. For that project, he has made about 50 checkins since then, so perhaps he's planning to do some serious work on that project.

Peter Starbek
A: 

I agree with Simon; http://www.stringtemplate.org/ is excellent, very well designed and is being actively maintained.

Robert