tornado 模板輸出被轉義的問題
按照例子试过了,以下的模板文件有问题:http://www.tornadoweb.org/documentation/overview.html?highlight=xsrf
<form action="/new_message" method="post"> {{ xsrf_form_html() }} <input type="text" name="message"/> <input type="submit" value="Post"/> </form>
这些会输出被转义的内容,与预期的不符合,提交会有错误. 参考以下内容后:所有的模板输出都已经通过 tornado.escape.xhtml_escape 自动转义(escape),这种默认行为,可以通过以下几种方式修改:将 autoescape=None 传递给 Application 或者 TemplateLoader、在模板文件中加入 {% autoescape None %}、或者在简单表达语句 {{ … }} 写成 {% raw …%}。另外你可以在上述位置将 autoescape 设为一个自定义函数,而不仅仅是 None。 改为:
<form action="/new_message" method="post"> {% raw xsrf_form_html() %} <input type="text" name="message"/> <input type="submit" value="Post"/> </form>
这样就ok了.
转义部分段落怎么实现?像django那样的。