我使用pystache
(在python3.4上)来模板HTML文件以通过电子邮件发送。
我有一个main.mustache
文件,其中一些标记将被其他.mustache
文件的内容替换。
所以我有这样的东西(简体版):
<body>
<table>
.......
{{some_params}}
....
</table>
{{special_warning}}
</body>
{{special_warning}}
标记仅在某些情况下使用,并且来自文件special_warning.mustache
:
在python脚本中,我会:
special_message = ''
if <some condition>:
special_message = renderer.render_path('special_warning.mustache', {})
proc_templ = renderer.render_path('main.mustache', {'special_warning': special_message , <the other params>})
我得到的结果是main.mustache
部分的正确消息,但是来自special_warning.mustache
的部分是HTML编码的:
<body>
<table>
.......
some_params
....
</table>
<table>
<tbody>
....
</tbody>
</table>
</body>
有什么办法阻止这种html编码吗?是pythonstring
在做这件事,还是pystache呈现来做呢?在
使用三方括号可避免html转义。我的so大胡子应该是:
相关问题 更多 >
编程相关推荐