SASS: Get value of existing background string and

2019-03-06 11:16发布

问题:

I'd like to additively build backgrounds in SASS/Compass, ignorant of the existing background string. I am able to accomplish by writing to a global var, but it seems sloppy.

Pseudo:

=mixin-add-icon
  // add a background icon
=mixin-add-gradient-from-color($color: blue !default)
  // add a background gradient
=mixin-add-texture-bg
  // add a bg texture

a
  background: blue
  +mixin-add-texture-bg
     // this should take the existing bg and add texture to it
  &.selected
    +mixin-add-gradient-from-color()
    +mixin-add-icon
       // these two should take the existing bgs strings from <a> and add to them

Am I missing something obvious? Thanks in advance.

回答1:

There isn't currently a way to access an object's properties via Sass, but Sass is an open project so you can always go and ask the developpers if such a feature would be possible on their Github repo.