To avoid using hard-coded URLs, you can use the url_for function as follows:
{% for ni in ['index', 'foo', 'bar', 'baz'] %} <li {%- if request.path == url_for(ni) %} class="active"{% endif %}><a href="{{ url_for(ni) }}">{{ ni | capitalize }}</a></li> {% endfor %}
In this case, index, foo, bar and baz will be the names of the functions that are used in your python code:
@app.route('/') def index():
MoepMan Mar 14 '16 at 11:18 2016-03-14 11:18
source share