C#模板引擎 [英] C# template engine

查看:126
本文介绍了C#模板引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个独立的,容易从C#code,模板引擎使用。
我想要做的就是创建一个HTML和XML文件,占位符数据,
并与我的code数据填充它们。
发动机需要支持循环(复制不止一个对象模板表单的部分)和条件(添加模板的部分只有当某些条件为真,最终的HTML / XML)。
有人可以推荐一个很好的选择对我来说,并添加一个链接到更多或更少,例如code样品,
以及如何使用推荐的组件满足我的需要一些文档?

I am looking for a stand-alone, easy to use from C# code, template engine. What I want to do is create an html and xml files with placeholders for data, and fill them with data from my code. The engine needs to support loops (duplicating parts of the template form more that one object) and conditions (add parts of the template to the final html/xml only if some conditions are true). Can someone recommend a good option for me, and add a link to more-or-less such code sample, and some documentation about how to use the recommended component for my needs?

感谢:)

只是想补充一点 - 我还需要使用循环复制表行,
甚至整个表(在html版本)和复杂的元素(XML版本)
再次感谢:)

Just wanted to add one more thing - I also need to use loops to duplicate table rows, or even entire tables (in the html version) and complex elements (in the xml version) Thanks again:)

推荐答案

我已经使用 StringTemplate的,提供了良好的效果。一些资源:

I have used StringTemplate with good results. Some resources:

  • Five minute introduction
  • Article on CodeProject showing example use from C#

这篇关于C#模板引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆