NVelocity 项目死了吗? 还有其他选择吗?

发布于 2024-07-16 06:50:23 字数 289 浏览 7 评论 0原文

我正在寻找 .NET/C# 的模板引擎来在我的应用程序中生成电子邮件通知。 我过去读过 NVelocity 并认为它适合我的需求,但似乎这个项目已经死了。

您是否仍然建议使用 NVelocity 来实现此目的,或者您可以建议任何替代方案吗?

注意:我发现了一些其他模板引擎,但这些大多是 ASP.NET MVC 的“视图引擎”(Brail、NHaml 等)。 但我想这些都不是我要找的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

黎夕旧梦 2024-07-23 06:50:23

Castle 项目分叉了该项目并一直在维护它,最近于 2010 年 12 月 10 日发布了版本 1.1.1。更多详细信息可以在 Castle Projects NVelocity 网站。 他们还对其进行了许多改进,详细信息可以在上找到他们的 NVelocity 改进页面。 该项目现在看起来已经死了,在 MonoRail 3 中,它已被基于 Razor 的 Castle Blade 所取代。

如果您正在寻找替代方案,那么我建议 来自 ASP.Net MVC3 的 Razor 视图引擎Spark View 引擎

开源项目 RazorEngine 允许您在 ASP.Net MVC 或网页之外使用 Razor View 引擎因此您可以使用它来生成模板电子邮件。

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.

べ映画 2024-07-23 06:50:23

您可以使用 brail 或 nhaml 独立版来生成 html 电子邮件。

nhaml 的核心(不确定 brail??)没有引用 MVC 或 ASP。

我使用 nhaml 生成 XPS 文档,以便从 win 表单应用程序进行打印和报告。

如果它必须是文本,也许 http://www.stringtemplate.org/

这是一个类似的问题如何使用 Brail作为独立的通用模板引擎(如 NVelocity)?

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

仙女山的月亮 2024-07-23 06:50:23

我认为没有理由不使用 NVelocity(Castle 项目分支)。 它很稳定,并且您的特定需求(电子邮件模板)可能不像使用 NVelocity 的其他项目中的需求那么复杂,因此您不应该期望出现任何问题。

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.

日暮斜阳 2024-07-23 06:50:23

Codeplex 上有一个项目。

http://www.codeplex.com/NVelocity

项目描述:
NVelocity 是一个非常流行的开源 java 模板引擎的端口
框架,速度1.6。
NVelocity 是一个用 C# 编写的纯 .Net 库,目前的目标是
框架版本3.5。

签入的初始源代码似乎直接来自
svn.castleproject.org。

CodePlex项目的创建者(用户名:TerryLiang)也是
早在 8 月份就从 nLucene 创建了一个。 对于那个项目,他有
从那时起,他进行了大约 50 次签到,所以也许他正计划做一些
对该项目进行认真的工作。

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.

晨与橙与城 2024-07-23 06:50:23

NVelocity 没有什么问题,只是很难找到该项目的最新版本。 Google 通常会将旧的 sourceforge 链接作为第一个点击,而 codeplex 链接是下一个最常见的链接。 正如佩尔韦兹·乔杜里提到的,获得它的地方是从城堡。 我们在工作中使用 Castle 版本的 NVelocity,它非常棒。

自从这个问题首次提出以来,还有另一个选择出现了,那就是微软的 T4。 大多数人认为 T4 是一个预编译生成器,因为它是第一次发布的,但实际上您现在可以使用它来生成生成器类并在运行时进行动态生成。 它称为预处理 T4 模板,您可以在此处阅读更多相关信息< /a>. 优点是它已经内置于 Visual Studio 中,因此您无需执行任何特殊操作即可开始使用。

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.

不必你懂 2024-07-23 06:50:23

由于 NVelocity 似乎已经死了(再次),我建议 DotLiquid。 现在不能说太多,因为我仍在评估它,但它看起来确实很有前途(并且针对我所关心的内容构建为 MonoTouch/MonoDroid 库)。

更新 [2012 年 6 月 11 日]

将“安全”类/集合作为模型的限制可能是令人头痛的主要根源。 在评估这款引擎时,你可能想从这一点开始。

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.

诗酒趁年少 2024-07-23 06:50:23

我同意西蒙的观点; http://www.stringtemplate.org/ 非常出色,设计得非常好,并且正在积极维护。

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

带上头具痛哭 2024-07-23 06:50:23

我无法为 DotLiquid 投票,所以只想添加我的评论 - 这似乎是一个正在积极开发的伟大平台。

凭借它们在 trunk 版本中(不在发布的 dll 中)的功能,如果您以这种方式注册它们,您可以使用 pocos,而无需从任何基类继承:

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

这解决了 Sorin 提到的令人头疼的问题。

StringTemplate 也是一个很棒的东西,但是太严格和限制了,模板太纯 View 了,用起来不实用……

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

如歌彻婉言 2024-07-23 06:50:23

您可以使用 .Net 中原始(且经常更新)的 Velocity Java 版本,方法是使用 IKVM 将其转换为程序集。 我已经成功地使用这种方式在 .Net 下生成代码。 您还可以看一下 StringTemplate。 StringTemplate 有 java 和 C# 版本。 您可以找到有关在 .Net 中使用 Velocity 的快速迷你教程 这里。 不过,我建议仔细查看 StringTemplate ,因为我认为它是一个更干净的模板引擎(我最近皈依的人)。

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

゛清羽墨安 2024-07-23 06:50:23

我建议使用 XSLT 进行模板化。 是的,它需要更多的时间来学习技术,但是这样你就拥有了比其他任何东西都更灵活的模板解决方案。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文