Is the NVelocity project dead? Are there alternati

2019-02-16 04:13发布

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.

10条回答
成全新的幸福
2楼-- · 2019-02-16 05:02

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.

查看更多
萌系小妹纸
3楼-- · 2019-02-16 05:09

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

查看更多
在下西门庆
4楼-- · 2019-02-16 05:13

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

查看更多
5楼-- · 2019-02-16 05:13

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

查看更多
登录 后发表回答