如何将Brail用作独立的通用模板引擎(如NVelocity)? [英] How to use Brail as a stand-alone general purpose templating engine (like NVelocity)?
问题描述
我一直在文本文件生成器中使用NVelocity作为独立的模板引擎. NVelocity的问题在于宏非常不稳定.我几乎得到的所有错误都来自错误的宏实现.
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.
如果我可以使用其他模板引擎(例如Brail),那将很酷.这样,我将只编写输出字符串的函数.
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.
嵌入Brail引擎的最佳方法是什么?我只想给它传递一个包含模板的字符串(而不是从磁盘读取),并且我想最小化外部依赖项的数量.
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.
编辑:我自己找到了答案. 看看这个源城堡中的文件.
I found the answer myself. Take a look at this source file from Castle.
推荐答案
Try nHaml or Spark as they both support full standalone or direct usage
它们都支持返回字符串等的标准c#函数
They both support standard c# functions that return strings etc
Spark是真正的HTML,nHaml是DRY HTML
Spark is real HTML, nHaml is DRY HTML
两个都很酷!
这篇关于如何将Brail用作独立的通用模板引擎(如NVelocity)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!