anvd
anvd

Reputation: 4047

Catch request.path with dynamic urls

In flask, i need to add a class when the request.path match a condition.

My problem is that request.path will be like

/users/history/job/john
/users/history/job/pedro
/users/history/role/fabio
/users/history/role/pedro
...

How can i catch that cases? This will not work due the dynamic part of url. There is any type of wildcards?

{% if request.path == "/users/history/job" %}active{% endif %}>
{% if request.path == "/users/history/role" %}active{% endif %}>

Upvotes: 0

Views: 247

Answers (1)

Matt Healy
Matt Healy

Reputation: 18531

Try something like this:

{% if "/users/history/job/" in request.path %}active{% endif %}>
{% if "/users/history/role/" in request.path %}active{% endif %}>

Upvotes: 1

Related Questions