Skip to content

Instantly share code, notes, and snippets.

@cahnory
Created August 5, 2014 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cahnory/c8abd8a1b347dda96b81 to your computer and use it in GitHub Desktop.
Save cahnory/c8abd8a1b347dda96b81 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
// attribute used instead of `class`
$class-attr: 'data-g';
// return attribute selector
@function g($class) {
@return '[#{$class-attr}~="#{$class}"]';
}
@mixin g($class, $direct: false) {
#{if($direct, '&', '')}#{g($class)} {
@content;
}
}
@mixin _g($class) {
@include g($class, true) {
@content;
}
}
a {
@include _g(foo) {
color: blue;
}
}
a {
@include _g(foo) {
color: yellow;
}
}
a {
@include _g(foo) {
@include _g(bar) {
color: green;
}
}
}
a[data-g~="foo"] {
color: blue;
}
a[data-g~="foo"] {
color: yellow;
}
a[data-g~="foo"][data-g~="bar"] {
color: green;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment