Can you recommend a .net template engine?

2019-01-03 23:22发布

I am looking for a .net templating engine - something simple, lightweight, stable with not too many dependencies. All I need it for at the moment is creating templated plain text and html emails. Can anyone give me a good recommendation?

If it helps at all - something like Java's Freemarker or Velocity libraries.

[UPDATE] Thanks for the answers so far - much appreciated. I am really intested in recommendations or war stories from when you have used these libraries. Seems to be the best way to make a decision without trying each in turn.

15条回答
放荡不羁爱自由
2楼-- · 2019-01-03 23:24

XCST (eXtensible C-Sharp Templates)

<ul>
   <c:for-each name='n' in='System.Linq.Enumerable.Range(1, 5)' expand-text='yes'>
      <li>{n}</li>
   </c:for-each>
</ul>
查看更多
叛逆
3楼-- · 2019-01-03 23:28

DotLiquid is very nice templating system for .NET.

It's derived from Ruby’s Liquid Markup, with requirements .NET Framework 3.5 or above.

查看更多
放荡不羁爱自由
4楼-- · 2019-01-03 23:29

NVELOCITY, though it's old ,last release in 2003, enough.

查看更多
虎瘦雄心在
5楼-- · 2019-01-03 23:31

I would recommend CodeSmith Generator. It is a template based code generator, with constant updates and an active community. Here is a list of templates that ship with CodeSmith Generator.

查看更多
走好不送
6楼-- · 2019-01-03 23:31

I think Mustache (http://mustache.github.com/) may fit the bill too.

查看更多
萌系小妹纸
7楼-- · 2019-01-03 23:34

RazorEngine, A templating engine built on Microsoft's Razor parsing engine.

https://github.com/Antaris/RazorEngine

Haven't used it, but I find it interesting because if you have an ASP.NET MVC background, you won't need to learn something new.

查看更多
登录 后发表回答