visual studio code – VSCode shows errors inside style tags due to jinja variables

causes a couple of warnings: a “property value expected”, and “at-rule or selector expected”

This is because the HTML syntax checking expects a value for the property, but doesn’t recognize the presence of the jinja variable. The other error is because jinja uses {{variable}} syntax and the syntax checker thinks the outer brackets should contain style rules. It doesn’t have any effect on the functionality but it does annoy me seeing these warnings, so ideally I would like to tell the syntax checker to ignore them.

The other solution would be to set a second variable like:

{% set bg_style_property = "style="background-color: {}"".format(color_default) %}

…and then use that to replace the entire style property within the tag

This is what I will eventually do if there isn’t a way to tell the linter to ignore the error.

Read more here: Source link