A similar question like this: Javascript is not recognizing a Flask variable
When I type things like this in vscode,
<script type="text/javascript">
var x ={{ data }};
</script>
it will always reformat like this
<script type="text/javascript">
var x = {
{
data
}
};
</script>
No longer a Jinja variable, and cannot really work in js.
So, is there such a plugin in vscode that can fix this problem?
The problem here lies with VSCode, especially with Syntax Highlighting and Formatting Extensions.
There is some conflict between some of your enabled extensions which - on save - format the JavaScript code in above way.
Disable all enabled formatting extensions in VSCode
I only activated the following:
This way on save the syntax doesn't get shredded anymore making the JavaScript recognize your {{ data }}
correctly.
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