17

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

Dave C
  • 7,729
  • 4
  • 49
  • 65
Nam Lee
  • 891
  • 1
  • 9
  • 20
  • 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. – Dave C Aug 05 '19 at 11:53

3 Answers3

34

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

vscode disable validate style html

Nam Lee
  • 891
  • 1
  • 9
  • 20
  • 14
    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: https://code.visualstudio.com/docs/getstarted/settings – Fran Verona Jun 08 '20 at 13:56
  • 5
    @FranVerona I think you meant `"html.validate.styles": false` since thats what the thread creator was looking for. – Johnny May 21 '21 at 16:08
  • This solution doesn't work with PHP files – migli Oct 05 '22 at 04:18
9

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

1

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

Turn off Intelephense feature

Tan Nguyen
  • 1,636
  • 1
  • 12
  • 9