Click here to Skip to main content
16,022,056 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

In my python Flask project I have this line of code in html file which is showing the error:
) expected

I don't know what is wrong the code

What I have tried:

HTML
<header class="masthead" style="background-image: url(' {{ url_for('static', filename='assets/img/home-bg.jpg')}} ')">
Posted
Comments
Peter_in_2780 3-Oct-24 3:13am    
Count your ( and ), { and }. They need to match and be nested correctly.
nyt1972 3-Oct-24 3:23am    
counted several times and they are nested correctly too
Richard Deeming 3-Oct-24 3:34am    
Perhaps it's confused by having single quotes nested inside single quotes? Try HTML-encoding the quotes:
style="background-image: url(&apos;{{ url_for('static', filename='assets/img/home-bg.jpg')}}&apos;)"
nyt1972 3-Oct-24 3:43am    
Good it worked thanks, even though VSCode is still showing the same error, but on browser in worked.

1 solution

As discussed in the comments, it's getting confused by the nested single quotes. HTML-encoding the outer pair allows it to work, although VS Code still shows an error.
HTML
<header class="masthead" style="background-image: url(&apos;{{ url_for('static', filename='assets/img/home-bg.jpg') }}&apos;)">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900