Pystache html 个字符在使用多个文件时被替换

Pystache html characters replaced when using multiple files

我正在使用 pystache(在 Python 3.4 上)模板 HTML 文件通过电子邮件发送。 我有一个 main.mustache 文件,其中一些标签将被其他 .mustache 文件的内容替换。 所以我有这样的东西(简化版):

main.mustache:

<body>
<table>
.......
{{some_params}}
....
</table>

{{special_warning}}
</body>

{{special_warning}} 标签仅在某些情况下使用,来自文件 special_warning.mustache:

<table>
  <tbody>
  <tr>
    <td>
      <h4 style="margin: 0; margin-bottom: 20px;"
        Well, this is odd. please re-do last action.
      </h4>
    </td>
  </tr>
  </tbody>
</table>

在我的 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>

&lt;table&gt;
  &lt;tbody&gt;
  ....
  &lt;/tbody&gt;
&lt;/table&gt;

</body>

有什么办法可以防止这种 html 编码吗?是 python string 做的,还是 pystache 渲染做的?

使用三括号避免 html 转义。所以我的 main.mustache 应该是:

<body>
<table>
.......
{{some_params}}
....
</table>

{{{special_warning}}}
</body>