Is the NVelocity project dead? Are there alternatives?
Asked Answered
B

10

27

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.

Byandby answered 30/3, 2009 at 21:22 Comment(0)
E
27

The Castle Project forked the project and have been maintaining it, and most recently released version 1.1.1 on 10 December 2010. 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. The project looks like it is now dead and in MonoRail 3, it has been replaced by Castle Blade which is based off Razor.

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

The open source project RazorEngine allows you to use the the Razor View engine outside of ASP.Net MVC or Web Pages so you can use it to generate templated emails.

Evelinevelina answered 30/3, 2009 at 21:29 Comment(4)
Castle had an NVelocity release in December of 2010.Provisional
I am working with ASP.NET 2.0 and needed a template library. Should I just go with the original NVelocity or is there a good alternative that is compatible with ASP.NET 2.0 (not MVC 2!).Lucrecialucretia
Hello, @Earlz its not dead and I see changes as recent as 21 days ago. I updated the links.Debora
I can see that NVelocity seems to be based on Engine version older than v1.6, though! It doesnt support text operators like "and"Debora
C
3

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 How to use Brail as a stand-alone general purpose templating engine (like NVelocity)?

Criseyde answered 1/4, 2009 at 10:7 Comment(0)
K
3

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.

Kelcie answered 26/4, 2009 at 17:40 Comment(0)
C
3

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.

Cleon answered 16/10, 2009 at 6:51 Comment(1)
I see message The site ahead contains harmful programs! and if I enter I See Project 'NVelocity' was not foundDrawshave
P
3

There's nothing wrong with NVelocity except that it's hard to find the most updated version of the project. Google typically turns up the old sourceforge link as the first hit, and the codeplex link is the next most common. The place to get it is from Castle as Pervez Choudhury mentioned. We use the Castle version of NVelocity at work, and it's great.

There's another option that emerged in the years since this question was first asked, and that is Microsoft's T4. Most people think of T4 as a pre-compilation generator as that was how it was first release, but actually you can now use it to generate a generator class and do dynamic generation at runtime. It's called a preprocessed T4 template, and you can read more about it here. The advantage is that it's already built into Visual Studio so you don't need to do anything special to get going.

Provisional answered 29/4, 2011 at 0:14 Comment(1)
There is something wrong with NVelocity, actually, as the latest version of NVelocity only has feature set up to about v1.5 of Velocity, meaning it doesnt support text operators like "and" instead of "&&" and "or" instead of "||" for exampleDebora
K
3

As NVelocity seems to have died (again), I would suggest DotLiquid. Cannot say much for now as I'm still evaluating it, but it sure looks promising (and builds as MonoTouch/MonoDroid library for what I'm concerned).

UPDATE [11 Jun 2012]

The constraint of having "safe" classes/collections as models may be a major source of headaches. When evaluating this engine, you may want to start from this point.

Kwon answered 7/6, 2012 at 13:5 Comment(0)
A
2

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

Academic answered 3/11, 2009 at 21:20 Comment(0)
L
2

I can't upvote Sorin for DotLiquid, so just want to add my comment - it seems like a great platform being actively developed.

And with features they have in trunk version (not in the released dll tho) you can use pocos without the need to inherit from any base class if you register them this way:

foreach (var type in {Assembly}.GetTypes())
    Template.RegisterSafeType(type, type.GetProperties().Select(p => p.Name).ToArray());

and this solved the headaches Sorin mentioned.

StringTemplate is also a great thing, but too strict and limiting, templates are too pure Views and it is inpractical to use...

Lasley answered 28/6, 2012 at 17:31 Comment(0)
S
1

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

Shamble answered 8/4, 2009 at 15:34 Comment(0)
S
0

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.

Sputnik answered 31/3, 2009 at 13:32 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.