Warm tip: This article is reproduced from stackoverflow.com, please click
html twig visual-studio-code drupal

How can I disable Visual Studio Code auto trimming whitespace of my HTML classes?

发布于 2020-03-28 23:15:19
<ul{{attributes.addClass('container container-desktop')}}>

when I press Command + / (autoformat), all my classes are without whitespace:

<ul{{attributes.addClass('containercontainer-desktop')}}>

I searched in the settings of Visual Studio Code for a setting. But did not found a solution to disable it.

Questioner
Slowwie
Viewed
69
technophyle 2020-01-31 17:46

That's a correct behavior from your IDE, because addClass with a string parameter is meant to add one class.

For multiple classes, refer to this documentation:

{%
  set classes = [
    'red',
    'green',
  ]
%}
<div{{ attributes.addClass(classes) }}></div>