Reputation: 119
I can find many posts about escapiang quotes for rendering them on a page, but in my case I want to make
<button onclick="window.location.href='{{ url_for("admin.pairs(entry.id)") }}';"> PP </button>
So onclick is followed by something that needs to be in quotes, and inside I have href which is followed by something else that needs to be in quotes, which is followed by url_for which contains something that needs to be in quotes. So I try to change between single and double quotes as such: " ' "" ' ", but it is not working. So in this case, which quotes need to be escaped? Or is it about something else?
Upvotes: 1
Views: 1360
Reputation: 1094
One approach is to store the result of url_for
in a variable and use it instead of calling url_for
.
{% set url = url_for("admin.pairs(entry.id)") %}
<button onclick="window.location.href='{{ url }}';">PP</button>
Upvotes: 4