Python 使用多个文件时替换Pystache html字符
我正在使用Python 使用多个文件时替换Pystache html字符,python,html,python-3.x,pystache,Python,Html,Python 3.x,Pystache,我正在使用pystache(在Python3.4上)为要通过电子邮件发送的HTML文件创建模板。 我有一个main.mustache文件,其中一些标记将被其他.mustache文件的内容替换。 所以我有这样的东西(简化版): 大胡子: 在python脚本中,我执行以下操作: special_message = '' if <some condition>: special_message = renderer.render_path('special_warning.must
pystache
(在Python3.4上)为要通过电子邮件发送的HTML文件创建模板。
我有一个main.mustache
文件,其中一些标记将被其他.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>})
有没有办法阻止这种html编码?是python
string
做的,还是pystache呈现做的?使用三个括号可以避免html转义。所以我的主要胡子应该是:
<body>
<table>
.......
{{some_params}}
....
</table>
{{{special_warning}}}
</body>
.......
{{some_params}}
....
{{{特别警告}}}
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>})
<body>
<table>
.......
some_params
....
</table>
<table>
<tbody>
....
</tbody>
</table>
</body>
<body>
<table>
.......
{{some_params}}
....
</table>
{{{special_warning}}}
</body>