I am working on a Django project. The code can work and run perfectly fine, there is no issue at all.
But Visual Studio Code indicates this part of code as syntax errors. However, in Sublime Text, there are no syntax errors shown.
I would like to get rid of the syntax errors which VSCode reports. I don't want to see the syntax errors. What is the correct way to add Jinja code to JavaScript to get rid of the syntax error? I am thinking about making a separate file or something else. What would you suggest?
VS Code doesn't recognize the Jinja code written inside the <script>
tag because you haven't installed the required extension and changed the settings.json
file so that Visual Studio Code can recognize the Jinja code written inside the <script>
tag.
I also encountered a similar problem and this is what I did to fix it. This is a screenshot showing VS Code reporting syntax errors before I fixed the problem. This answer to a similar question gave me the clue.
enmet.preferences:{}
part:"emmet.preferences": {
},
"files.associations": {
"*.html": "jinja-html"
},
"emmet.includeLanguages": {
"jinja-html": "html",
},
}
"jinja-html": "html"
should have been added to the "Include Languages" setting and the item "*.html": "jinja-html"
should have been added to the "Files: Associations" setting. Note that "*.embeddedhtml": "html"
is the system default setting for "Files: Associations".Hopefully, you will find my answer helpful.