为什么我得到jinja2.exceptions.TemplateSyntaxError:unexpected'}'

时间:2018-02-04 06:49:10

标签: javascript python html flask jinja2

我无法弄清楚这个错误发生的原因,

{% block body %}

<!-- Content -->


<div class="container">
    <div class="row">
    <div class="col-lg-12">
                          <br>
                                    <div class="header"><h3>Ongoing Matches</h3></div>
                                    <br>
                                <h3>{{ datestring_today }}</h3>
                          <br>
                              <script src="//www.cricruns.com/widget/widget_livebar.js" type="text/javascript"></script>
                    <! --summary---->
                         <div class="list-group">
                          {% for  game in gamest %}
                                {% if game[]}
                           <a class="score-size text-xs-center nounderline list-group-item list-group-item-action" >
                             <div class="row">
                              <div class="col-xs-4">
                                  {% if game["Batting_team_img"] %}
                                  <img class="team-logo" src="/static/{{ game["Batting_team_img"] }}">
                                  {% endif %}
                                  {{ game["Batting team"] }} {{ game["runs10"] }}
                                  </b>
                                  <br>
                                  {{ game["wickets10"] }}
                              </div>

                              <div class="col-xs-4 broadcast-column">
                                  <div class="final-text">
                                      {{ game["status2"] }}
                                  </div>
                                  <div class="broadcaster">
                                      {{ game["series2"] }}
                                  </div>
                              </div>

                              <div class="col-xs-4">
                                    {% if game["Bowling_team_img"] %}
                                    <img class="team-logo" src="/static/{{ game["Bowling_team_img"] }}">
                                    {% endif %}
                                    {{ game["Bowling team"] }} {{ game["runs20"] }}
                                    </b>
                                    <br>
                                    {{ game["wickets20"] }}
                              </div>
                             </div>
                            </a>
                          {% endfor %}
                             </div>
                         </div>
                     </div>
                     <br></br>
                     <div class="row">
                           <div class="col-lg-12">
                          <table class="standings-datatable table table-sm">
                                  <thead>
                                        <tr  class="bg-primary text-white">
                                                  <th class="text-lg-center">Match Type</th>
                                                  <th class="bg-danger text-lg-center">Series</th>
                                                  <th class="bg-dark text-lg-center">Team vs Team</th>
                                                  <th class="bg-info text-lg-center">Status</th>
                                                  <th class="bg-light text-lg-center">Batting </th>
                                                    <th class="bg-primary text-lg-center">Runs</th>
                                                    <th class="bg-secondary text-lg-center">Wickets</th>
                                                    <th class="bg-success text-lg-center">Overs</th>
                                                    <th class="bg-transparent text-lg-center">Batsman Name</th>
                                                    <th class="bg-warning text-lg-center">Batsman Score</th>
                                          <th class="bg-transparent text-lg-center">Batsman Name</th>
                                                    <th class="bg-warning text-lg-center">Batsman Score</th>
                                                    <th class="bg-transparent text-lg-center">Bowler Name</th>
                                                    <th class="bg-warning text-lg-center">Bowler Wickets</th>
                                                    <th class="bg-transparent text-lg-center">Bowler Name</th>
                                                    <th class="bg-warning text-lg-center">Bowler Wickets</th>
                                        </tr>
                                  </thead>
                                <tbody>
                                {% for game in gamest %}
                                    <tr class="table table-bordered">
                                          <td >{{ game['matchtype2'] }}</td>
                                                  <td>{{ game['series2'] }}</td>
                                                  <td>{{ game['teams2'] }}</td>
                                                  <td>{{ game['status2'] }}</td>
                                          <td>{{ game['Batting team'] }}</td>
                                                    <td>{{ game['runs10'] }}</td>
                                                    <td>{{ game['wickets10'] }}</td>
                                                    <td>{{ game['overs10'] }}</td>
                                                    <td>{{ game['name1'] }}</td>
                                                    <td>{{ game['runs1'] }}</td>
                                          <td>{{ game['name2'] }}</td>
                                                    <td>{{ game['runs2'] }}</td>
                                          <td>{{ game['name5'] }}</td>
                                                  <td>{{ game['wickets5'] }}</td>
                                                    <td>{{ game['name6'] }}</td>
                                                  <td>{{ game['wickets6'] }}</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                                </table>
                        </div>
                            </div>
                            <br></br>

                            <table class="standings-datatable table table-sm">
                                <thead class="thead-inverse">
                                 <tbody>
                                 <tr>

                                            <th class="bg-dark text-lg-left">TEAM</th>
                                            <th class="bg-dark text-lg-center">M</th>
                                            <th class="bg-dark text-lg-left">W</th>
                                            <th class="bg-dark text-lg-left">L</th>
                                            <th class="bg-dark text-lg-left">T</th>
                                            <th class="bg-dark text-lg-left">N/R</th>
                                            <th class="bg-dark text-lg-left">PT</th>
                                            <th class="bg-dark text-lg-left">NRR</th>
                                            <th class="bg-dark text-lg-left">FOR</th>
                                            <th class="bg-dark text-lg-left">AGAINST</th>



                                 </tr>
                                </thead>

                                    {% for key in tabledata %}
                                            <tr>

                                            <td>{{ key['Sydney image'] }}</td>
                                            <td>{{ key['Sydney Thunder M'] }}</td>
                                            <td>{{ key['Sydney Thunder For'] }}</td>
                                            <td>{{ key['Sydney Thunder PT'] }}</td>
                                            <td>{{ key['Sydney Thunder W'] }}</td>
                                            <td>{{ key['Sydney THunder AGAINST'] }}</td>
                                            <td>{{ key['Sydney THunder N/R'] }}</td>
                                            <td>{{ key['Sydney THunder L'] }}</td>
                                            <td>{{ key['Sydney THunder T'] }}</td>
                                            <td>{{ key['Sydney THunder NRR'] }}</td>

                                            </tr>
                                            <tr>

                                            <td>{{ key['Brisbane image'] }}</td>
                                            <td>{{ key['Brisbane Heat  M'] }}</td>
                                            <td>{{ key['Brisbane Heat  For'] }}</td>
                                            <td>{{ key['Brisbane Heat  PT'] }}</td>
                                            <td>{{ key['Brisbane Heat  W'] }}</td>
                                            <td>{{ key['Brisbane Heat  AGAINST'] }}</td>
                                            <td>{{ key['Brisbane Heat  N/R'] }}</td>
                                            <td>{{ key['Brisbane Heat  L'] }}</td>
                                            <td>{{ key['Brisbane Heat  T'] }}</td>
                                            <td>{{ key['Brisbane Heat NRR'] }}</td>


                                            </tr>

                                            <tr >

                                                <td>{{ key['Adelaide strikers image'] }}</td>
                                                <td>{{ key['Adelaide Strikers M'] }}</td>
                                                <td>{{ key['Adelaide Strikers For'] }}</td>
                                                <td>{{ key['Adelaide Strikers PT'] }}</td>
                                                <td>{{ key['Adelaide Strikers W'] }}</td>
                                                <td>{{ key['Adelaide Strikers AGAINST'] }}</td>
                                                <td>{{ key['Adelaide Strikers N/R'] }}</td>
                                                <td>{{ key['Adelaide Strikers L'] }}</td>
                                                <td>{{ key['Adelaide Strikers T'] }}</td>
                                                <td>{{ key['Adelaide Strikers NRR'] }}</td>
                                            </tr>
                                            <tr >

                                                <td>{{ key['Horbat Hurricanes image'] }}</td>
                                                <td>{{ key['Horbat Hurricanes M'] }}</td>
                                                <td>{{ key['Horbat Hurricanes For'] }}</td>
                                                <td>{{ key['Horbat Hurricanes PT'] }}</td>
                                                <td>{{ key['Horbat Hurricanes W'] }}</td>
                                                <td>{{ key['Horbat Hurricanes AGAINST'] }}</td>
                                                <td>{{ key['Horbat Hurricanes N/R'] }}</td>
                                                <td>{{ key['Horbat Hurricanes L'] }}</td>
                                                <td>{{ key['Horbat Hurricanes T'] }}</td>
                                                <td>{{ key['Horbat Hurricanes NRR'] }}</td>
                                            </tr>
                                            <tr >

                                                <td>{{ key['Melbourne Renegades image'] }}</td>
                                                <td>{{ key['Melbourne Renegades M'] }}</td>
                                                <td>{{ key['Melbourne Renegades For'] }}</td>
                                                <td>{{ key['Melbourne Renegades PT'] }}</td>
                                                <td>{{ key['Melbourne Renegades W'] }}</td>
                                                <td>{{ key['Melbourne Renegades AGAINST'] }}</td>
                                                <td>{{ key['Melbourne Renegades N/R'] }}</td>
                                                <td>{{ key['Melbourne Renegades L'] }}</td>
                                                <td>{{ key['Melbourne Renegades T'] }}</td>
                                                <td>{{ key['Melbourne Renegades NRR'] }}</td>
                                            </tr>
                                            <tr >

                                                <td>{{ key['Melbourne stars image'] }}</td>
                                                <td>{{ key['Melbourne stars M'] }}</td>
                                                <td>{{ key['Melbourne stars For'] }}</td>
                                                <td>{{ key['Melbourne stars PT'] }}</td>
                                                <td>{{ key['Melbourne stars W'] }}</td>
                                                <td>{{ key['Melbourne stars AGAINST'] }}</td>
                                                <td>{{ key['Melbourne stars N/R'] }}</td>
                                                <td>{{ key['Melbourne stars L'] }}</td>
                                                <td>{{ key['Melbourne stars T'] }}</td>
                                                <td>{{ key['Melbourne stars NRR'] }}</td>
                                            </tr>
                                            <tr >

                                                <td>{{ key['Perth Scorchers image'] }}</td>
                                                <td>{{ key['Perth Scorchers M'] }}</td>
                                                <td>{{ key['Perth Scorchers For'] }}</td>
                                                <td>{{ key['Perth Scorchers PT'] }}</td>
                                                <td>{{ key['Perth Scorchers W'] }}</td>
                                                <td>{{ key['Perth Scorchers AGAINST'] }}</td>
                                                <td>{{ key['Perth Scorchers N/R'] }}</td>
                                                <td>{{ key['Perth Scorchers L'] }}</td>
                                                <td>{{ key['Perth Scorchers T'] }}</td>
                                                <td>{{ key['Perth Scorchers NRR'] }}</td>
                                            </tr>
                                            <tr >

                                                <td>{{ key['Sydney Sixers image'] }}</td>
                                                <td>{{ key['Sydney Sixers M'] }}</td>
                                                <td>{{ key['Sydney Sixers For'] }}</td>
                                                <td>{{ key['Sydney Sixers PT'] }}</td>
                                                <td>{{ key['Sydney Sixers W'] }}</td>
                                                <td>{{ key['Sydney Sixers AGAINST'] }}</td>
                                                <td>{{ key['Sydney Sixers N/R'] }}</td>
                                                <td>{{ key['Sydney Sixers L'] }}</td>
                                                <td>{{ key['Sydney Sixers T'] }}</td>
                                                <td>{{ key['Sydney Sixers NRR'] }}</td>
                                            </tr>


                                  {%endfor%}
                             </tbody>
                            </table>


                        <div class="row">
                        <div class="col-lg-6">
                                <a class="twitter-timeline" href="https://twitter.com/nikilr14/lists/hot-cric-tweets?ref_src=twsrc%5Etfw"data-aria-polite="assertive"data-chrome="noheader nofooter noborders scrollbar"data-width="500"
                             data-height="500">A Twitter List by nikilr14</a>
                            <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                        </div>

                            <div class="col-lg-6">
                                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<iframe id="youtube_video" width="600" height="340" frameborder="0" allowfullscreen></iframe>

<script>
var channelID = "UCSRQXk5yErn4e14vN76upOw";
$.getJSON('https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fwww.youtube.com%2Ffeeds%2Fvideos.xml%3Fchannel_id%3D'+channelID, function(data) {
   var link = data.items[0].link;
   var id = link.substr(link.indexOf("=")+1);
    $("#youtube_video").attr("src","https://youtube.com/embed/"+id + "?controls=0&showinfo=0&rel=0");
});
</script>
                            </div>
                            <div class="row">
                                    <!-- Bballbreakdown -->
                                    <div class="col-lg-6">
                                            {% for title, link in cricinfo_posts.items() %}
                                                    <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="{{ link }}">
                                                            {{ title }} <img class="team-logo" src="/static/images/espncricinfo.png">

                                                    </a>
                                                    <br>
                                            {% endfor %}
                                    </div>
                                    <!-- Fansided Nylon Calculus -->
                                    <div class="col-lg-6">
                                            {% for title, link in cricbuzz_posts.items() %}
                                                    <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="{{ link }}">
                                                            {{ title }} <img class="team-logo" src="/static/images/cricbuzz.png">
                                                    </a>
                                                    <br>
                                            {% endfor %}
                                    </div>
                                </div>

                                    <div class="col-lg-6">
                                            {% for title, link in yahoonews_posts.items() %}
                                                    <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="{{ link }}">
                                                            {{ title }} <img class="team-logo" src="/static/images/yahoocricnews.png">
                                                    </a>
                                                    <br>
                                            {% endfor %}
                                    </div>
                                    <div class="col-lg-6">
                                            {% for title, link in bigbash_posts.items() %}
                                                    <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="{{ link }}">
                                                            {{ title }} <img class="team-logo" src="/static/images/bbl.png">
                                                    </a>
                                                    <br>
                                            {% endfor %}
                                    </div>
                            </div>




                                    <!-- Reddit -->
                                    <div class="row">
                                        <div class="col-lg-6">
                                            {% for i in range(1, 10, 2) %}
                                                <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="https://reddit.com{{ hot_Cricket_posts[i].permalink }}">
                                                    {{ hot_Cricket_posts[i].title }} <img class="team-logo" src="/static/images/reddit.png">
                                                </a>
                                                <br>
                                            {% endfor %}
                                        </div>
                                        <div class="col-lg-6">
                                            {% for i in range(2, 11, 2) %}
                                                <a class="reddit-boxes nounderline list-group-item list-group-item-action" href="https://reddit.com{{ hot_Cricket_posts[i].permalink }}">
                                                    {{ hot_Cricket_posts[i].title }} <img class="team-logo" src="/static/images/reddit.png">
                                                </a>
                                                <br>
                                            {% endfor %}
                                        </div>
                                    </div>
</div>



{% endblock %}

抱歉代码结构不规则,代码中的任何改进都会受到赞赏,我在代码中看了每个'}'但我没有发现任何错误的语法。我查看了jinja2文档,我的代码遵循每个语法规则为文档中提到但我得到模板语法错误,如果你想了解更多有关代码的信息,请随时提出,谢谢。

1 个答案:

答案 0 :(得分:1)

查看以下行:

{% for  game in gamest %}
    {% if game[]}
...

您错过了结束%字符。

您可能也会收到有关game[]的错误。