I am using Flask/Jinja2 and Bootstrap 3.
I'd like to add class="active"
to the current navigation element.
Those elements are stored in prog_ids
:
/programme/23022014
/programme/24022014
/programme/25022014
I followed some examples like this one and my HTML code is :
<ul class="nav nav-pills ">
{% for prog_id in prog_ids %}
{% macro nav_link(endpoint, prog_id) %}
{% if request.endpoint.endswith(endpoint) %}
<li class="active">
<a href="{{ url_for(endpoint) }}">
<span class="badge pull-right">-</span>
{{prog_id|strftime_b}}
</a>
</li>
{% else %}
<li>
<a href="{{ url_for(endpoint) }}">
<span class="badge pull-right">-</span>
{{prog_id|strftime_b}}
</a>
</li>
{% endif %}
{% endmacro %}
{% endfor %}
</ul>
Is there any error in the code above ? Because, it shows nothing .
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…