Error "property value expected css" and "at-rule or selector expected css" editing Go template in VSCode
Asked Answered
P

3

22

I'm using Go and package html/template. This is my code in mypage.tmpl:

<div class="col-sm-1">
        <i class='fas fa-square companies-color' style="color: {{.Company.Color}}"></i>
</div>

But I get errors in VSCode:

property value expected css(css-property value expected)

and

at-rule or selector expected css(css-rule selector expected)

when I try {{ }} in style html.

screen shot of VSCode error messages

Proficiency answered 5/8, 2019 at 4:19 Comment(1)
I don't use VSCode, but this looks like your editor thinks your *.tmpl file should be valid CSS and is complaining that it's not valid (which it isn't, it only becomes valid CSS once the template is executed). You either need a plug-in/setting that recognises Go template files (e.g. understands {{…}}) or turn off syntax checking for *.tmpl files.Broz
P
40

I have found solution. Turn off html validate styles in setting's vscode

vscode disable validate style html

Proficiency answered 14/8, 2019 at 13:25 Comment(3)
Please note that this will affect all projects opened. In case you just want to turn off this setting for a particular workspace, you should create a folder called .vscode on the root of your project, then a file called settings.json inside, and add "html.validate.styles": true. More info about this method can be found here: code.visualstudio.com/docs/getstarted/settingsStow
@FranVerona I think you meant "html.validate.styles": false since thats what the thread creator was looking for.Inexperience
This solution doesn't work with PHP filesIreland
R
10

Hi I fixed this this by installing the Django extension in VsCode

Rhetoric answered 10/1, 2021 at 1:37 Comment(4)
Nice Hack ! Thanks ;)Harakiri
For me this is the better solution, thanks! :)Babylonian
Confirmed this is working, this is much better solution but it kinda bothers me the need to install another extension that probably won't have any uses aside from removing annoying red lines on vscode.Dionnadionne
There are several extensions. I have installed this marketplace.visualstudio.com/… and worked for me as well.Pocketful
E
1

For people using PHP Intelephense, turn off Intelephense > Diagnostics: Embedded Languages should work.

Turn off Intelephense feature

Eichmann answered 25/2, 2023 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.