烧瓶Python HTML

我正在尝试将我的原始HTML文件呈现到主烧瓶python项目中,但是当我运行它时,它给出此错误“ jinja2.exceptions.TemplateSyntaxError:意外的'%'”,有人可以帮忙吗?这将是一种荣幸。当前正在为此项目使用PyCharm IDE。

<html>
    <head>
        <title></title>
    </head>
    <body>
      {{% for post in posts %}}
      <h1>{{post.title}}</h1>
      <p>By {{post.author}} on {{post.date_posted}}</p>
      <p>By {{post.content}}</p>
      {{%end for%}}
    </body>
yiqwer 回答:烧瓶Python HTML

在执行条件语句时,必须使用以下语法将其括起来:
{% if true %}
将变量传递到模板时,请使用双括号:
<span>MyVar has the value: {{ myvar }}</span>

要注意的另一件事是end for应该是endfor

,

烧瓶语法类似于{% code %} ...而不是{{% code %}}{{}}只是为了将vars用作模板),它是{% endfor %}而不是:{{%end for%}}。 / p>

本文链接:https://www.f2er.com/3130919.html

大家都在问