2017-06-04 6 views
0

私は以下のようなHTMLコードを持っている:jinja2.exceptions.TemplateSyntaxErrorを解決するには?

<html> 
 
<head> 
 
\t <title>Booking Lah</title> 
 
\t <meta charset="utf-8"> 
 
\t <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
\t <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 %}}

を。

答えて

0

あなたのテンプレートでは{%%}の代わりに{{%%}}を使用しています。

{%は、ディレクティブ(ループ、条件付き、...)で、{{は置換用です。詳細は、docをご参照ください。

+0

ありがとうございました。私はそれを知らなかったけれど、今は別の問題があります。ループ内の要素を表示しません。 –

+0

'tmplt = Template(...)'そして 'tmplt.render(rows = {{'名前': '最初の行'、 '画像'、 '最初の画像'}、{名前}: '2番目の行'、 '画像2': '2番目の画像'}]) ' 。 –

関連する問題