Alma
Alma

Reputation: 119

How to handle quotes in quotes in quotes with jinja/html?

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

Answers (1)

Simeon Nedkov
Simeon Nedkov

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

Related Questions