less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

How variables in comments #3510

Closed cipchk closed 4 years ago

cipchk commented 4 years ago

Let's say I have the following map and iterate over it with the each-function:

@values: 9, 12, 24;
each(@values, {
  /**
   * Font size, same: @{value}
   */
  .font-size-@{value} {
    font-size: ~"@{value}px";
  }
});

Output:

/**
   * Font size, same: @{value}
   */
.font-size-9 {
  font-size: 9px;
}
/**
   * Font size, same: @{value}
   */
.font-size-12 {
  font-size: 12px;
}
/**
   * Font size, same: @{value}
   */
.font-size-24 {
  font-size: 24px;
}

How to fill variables in comments, like this:


/**
   * Font size, same: 9
   */
.font-size-9 {
  font-size: 9px;
}
/**
   * Font size, same: 12
   */
.font-size-12 {
  font-size: 12px;
}
/**
   * Font size, same: 24
   */
.font-size-24 {
  font-size: 24px;
}

I hope to get comments by parsing css (like css-tree) for ide intellisense.

matthew-dean commented 4 years ago

The appropriate place to ask this is Stack Overflow, but the quick answer is:

@var: 9;
e("/**
   * Font size, same: @{var}
   */");