Errors in VSCode Editing Go Template: "CSS Property Value Expected" and "At-Rule or Selector Expected"
When editing Go templates using the html/template package, errors like "property value expected css" and "at-rule or selector expected css" may arise when using {{ }} within the style attribute of HTML elements.
Solution:
To resolve these errors, disable the "HTML Validate Styles" setting in VSCode's settings. Here are the steps:
Explanation:
The VSCode Go plugin uses htmlhint to validate HTML and CSS. However, htmlhint expects pure CSS rules within the style attribute. Since Go templates allow for dynamic values (e.g., {{.Company.Color}}), the validator raises these errors. Disabling the HTML validation for styles allows these dynamic values to be parsed correctly without affecting the actual rendering of the styles.
The above is the detailed content of Why is VSCode Showing 'CSS Property Value Expected' and 'At-Rule or Selector Expected' Errors in Go Templates?. For more information, please follow other related articles on the PHP Chinese website!