I am using Flask do develop a web app to visualize data retrieved from a database. I want to include a chart which requires a Jinja for loop to accomplish population of the chart. When I place the for loop inside the JavaScript <script> tag in an .html document VS Code shows a syntax error. It's fine outside the <script> tag. I tried the exact same code in Eclipse and receive no formatting error. I have also noticed that Jinja text tags such as '{{label}}' can be entered inside JavaScript with no syntax error showing.
screen shot of syntax error in VS Code
I have spent a lot of development time in VS Code and would prefer to not have to switch IDEs at this stage. Any help would be greatly appreciated.
After a bit of experimenting I found the Python Extension Pack by Don Jayamanne. It solved the syntax error problem. I still get some strange color coding, but everything seems to be working. If anyone has a suggestion of a better extension pack, I would love to give it a try.
I changed the HTML to Jinjascreenshot in the bottom right and it solved the issue for me.
Thanks for the earlier posts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With