postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
419 stars 35 forks source link

Variable-like syntax in content property #35

Closed KELiON closed 8 years ago

KELiON commented 8 years ago

It is possible to have variable-like syntax in content property, i.e.

.selector::before { 
  content: '$x';
}

Currently it will raise an error (undefined variable $x). I wanted to do PR with fix, but I think it is topic to discuss, what is proper behaviour in this case? I see two options:

1) Use js-like syntax in strings in css, like content: '$one' will not be changed, but content: '${one}' will replace ${one} to value of $one; 2) Use escapes for $ in this case, like content: \$one will be changed to content: $one and content: $one will be changed to variable value.

Any thoughts?

ai commented 8 years ago

Quick solution is to use silent mode.

Maybe we can add escaping? Like \$x?

studiosciences commented 8 years ago

The unicode escape syntax can address this... content: "\0024x"; /* "$x" */

ai commented 8 years ago

@studiosciences thank! I added this advice to docs 52e1dd8