gpt4 book ai didi

python - 如何解决 jinja2.exceptions.TemplateSyntaxError?

转载 作者:太空宇宙 更新时间:2023-11-03 15:09:26 32 4
gpt4 key购买 nike

我有如下 HTML 代码:

<html>
<head>
<title>Booking Lah</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style type="text/css">
.card {
height: 450px;
}
.card-image {
max-height: 300px;
max-width: 350px;
width: auto;
vertical-align: middle;
}
.image-display {
height: 300px;
width: auto;
}
.helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.image-caption {
height: 100px;
}
.star {
color: orange;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="home.php">Booking Lah</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="register.php"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</nav>

<div class="container">
<div class="row">

{{% for row in rows %}}
<div class="col-sm-4 card">
<div class="image-display">
<center>
<span class="helper"></span><img src="{{row['imgurl']}}" class="card-image"><br>
</center>
</div>
<div class="image-caption">
<center>
<h1><a href="#">{{row["name"]}}</a></h1>
<h2>
<span class="glyphicon glyphicon-star star"></span>
</h2>
</center>
</div>
</div>
{{% endfor %}}

</div>
</div>

</body>
</html>

我收到了这样的错误:

jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: unexpected '%' File "/home/m26415086/UHTOS/templates/home.html", line 55, in template {{% for row in rows %}}

我已经尽了一切努力,但没有任何改变。

最佳答案

在您的模板中,您使用 {{%%}} 而不是 {%%} >.

{% 用于指令(循环、条件等),{{ 用于替换。这是doc以供进一步引用。

关于python - 如何解决 jinja2.exceptions.TemplateSyntaxError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44351786/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com