jinja temp的javascript

2024-09-25 20:30:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用一个Jinja模板来使用数据来填充网页。你知道吗

代码是: ““

<div class="container">
  <button type="button" class="btn btn-md btn-info collapsed" data-toggle="collapse" data-target="#title">Programme Title</button>
  <div id="title" class="collapse">
    <!-- START of TABLE  -->    


    <table>
        <thead>
            <th> Programme Title </th>
            <th class="midc"> Lead (s) </th>
            <th class="midc"> Theme </th>
            <th class="midc"> Cluster </th>
        </thead>
        <tbody>
            {% for p in progs %}
            <tr>
            <td><a href="programmes/{{ p.programme_ID }}"><mark>{{ p.Programme }}</mark></a> </td>
            {% endfor %}                    
            <td>
            {% for pc in pclus %}
            <label for="content"> Lead(s) </label>
            <select name="staffroles">
                    <option value=Null></option>
                    {% if pc.cluster_ID == pclus % }                        
                        <option value={{ p.cluster_ID }} selected> {{ p.Name }}</option>
                    {% else %}
                        <option value={{ pc.cluster_ID }}> {{ p.Name }}</option>
                    {% endif %}
            </td>
            <td class="midc"> {{ p.cluster_id }} </td>
            </tr>                                   
            {% endfor %}
            </select>
        </tbody>

    </table>


    </div>
    <!-- END OF TABLE -->
</div> 

第二个块“{%forpc-in-pclus%}”用于下拉列表。你知道吗

我把一段代码注释掉了。我删除了注释掉的代码。你知道吗

我收到一条新的错误信息。你知道吗

错误消息: 金贾2号。异常。模板语法错误:意外的'}'


Tags: 代码individforbuttonclasstd
1条回答
网友
1楼 · 发布于 2024-09-25 20:30:11

在您的{% if pc.cluster_ID == pclus % }行中,在}前面的末尾有一个额外的空格,这使jinja认为if pc.cluster_ID == pclus %是一个完整的python语句。去掉空格,错误就应该消失了。你知道吗

相关问题 更多 >