我一直在我的文本文件生成器中使用NVelocity作为独立的模板引擎。 NVelocity的问题在于宏非常不稳定; 我得到的所有错误都来自错误的宏实现。
如果我可以使用其他模板引擎,比如Brail,那将会很酷。 这样我就会编写输出字符串的函数。
什么是嵌入Brail发动机的最佳方式? 我想传递一个包含模板的字符串(不是从磁盘读取),我想尽量减少外部依赖项的数量。
编辑:我自己找到了答案。 看看Castle的这个源文件 。
I've been using NVelocity as a stand-alone templating engine in my text file generator. The problem with NVelocity is that the macros are quite shaky; pretty much all errors I get are from faulty macro implementation.
It would be cool if I could just use some other templating engine, such as Brail. That way I would just write functions that output strings.
What's the best way of embedding Brail engine? I would like to just pass it a string containing the template (not reading from disk), and I would like to minimize the number of external dependencies.
EDIT: I found the answer myself. Take a look at this source file from Castle.
最满意答案
尝试使用nHaml或Spark,因为它们都支持完全独立或直接使用
它们都支持返回字符串等的标准c#函数
Spark是真正的HTML,nHaml是DRY HTML
两者都很酷!
Try nHaml or Spark as they both support full standalone or direct usage
They both support standard c# functions that return strings etc
Spark is real HTML, nHaml is DRY HTML
Both very cool!
更多推荐
发布评论