search

Home  >  Q&A  >  body text

python - flask jinjia2 {% include "aa.html" %}出现jinja2.exceptions.TemplateSyntaxError错误

我用flask做一个网站,现在我有一个模板文件base.html,其中包含以下代码

{% block header %}
{% include "header.html"%}
{% endblock %}

而现在header.html包含以下代码:

<pre><code>
      if [ ${#array[@]} -eq 2  -a ${array[0]} = $2 ]; 
</code></pre>

现在显示的时候出现错误:

jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: Missing end of comment tag

我查了一下文档,应该是{#在jinja中表示注释,请问如何在包含一个html文件时对这些特殊字符组合进行处理?

PHPzPHPz2804 days ago961

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:38:34

    {% raw %}
    blahblahblah
    {% endraw %}
    

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:38:34

    I also encountered the same problem, but the reason for the error was indeed that I used the id selector and media query in the css (the id selector was used for some reasons). There was no problem during the test, but it went online. Previously, the regression test used compressed files, but the result was that I fell to my knees, @media(xxx){#xxx}, and reported an error directly. It took me a long time to find out

    reply
    0
  • Cancelreply