Escaping double quotes while rendering in Jinja2

前端 未结 2 1304
广开言路
广开言路 2021-02-14 07:34

I\'m using Jinja2 to create Golang code using Python3. I need to pass some parameters in quotes to a function in my final code, but Jinja2 isn\'t escaping double quotes. My pyth

相关标签:
2条回答
  • 2021-02-14 08:14

    The alternative way to do this would have been

    e.({{ function|safe }})
    

    which prevents auto-escaping.

    0 讨论(0)
  • 2021-02-14 08:23

    This is due to Jinja2 autoescaping. As described in the documentation, the recommended way to avoid this is to wrap the text in a Markup object.

    0 讨论(0)
提交回复
热议问题