A working template-engine for IronPython?
I'd love to use a nice template-engine with IronPython but havent succeded doing so. Would be best to be able to without needing to add Python standard lib's. Dont know if that's possible.
I like the Ruby E开发者_运维技巧rb syntax, and hoped to be able to use something similar.
My personal favourite is Jinja2, but it's much closer to Django syntax than to ERB syntax (Mako seems reasonably close in that respect). You can take a look at this question about Python templating engines for more ideas.
I can vouch for Jinja2 working on IronPython. It does need the standard library (and I'd guess most of the others do too), and beware of this bug if you're running IronPython < v2.7b1 (see the comments for a workaround specific to Jinja2 for earlier releases of IronPython), as well as this unicode
bug, but otherwise it works great.
One thing to keep in mind is that template engines tend to import a lot of code (even if it's only standard libraries), which makes them slow to load on IronPython, but fast after the initial JIT compilation.
Yes - the built in way is conveniant enough for my needs:
def content(result):
return """
<p>Thank you for posting!</p>
<p>Result : {result}</p>
""".format(result=result)
精彩评论