Skip to content

Instantly share code, notes, and snippets.

@matori
Created January 13, 2015 03:51
Show Gist options
  • Save matori/866fd5793cee165176b8 to your computer and use it in GitHub Desktop.
Save matori/866fd5793cee165176b8 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
@function selector-to-string($selector: "") {
@if $selector == "" {
$selector: &;
}
$selector-length: str-length(#{$selector});
@return #{str-slice(#{$selector}, 1, $selector-length)};
}
x {
content: "#{selector-to-string()}";
}
y {
content: "#{selector-to-string('.container')}";
}
%extend {
width: 100%;
&-child {
$this: selector-to-string();
font-size: 16px;
&--red {
@extend #{$this};
color: red;
}
&--blue {
@extend #{$this};
color: blue;
}
}
}
.test {
@extend %extend;
&-a {
@extend %extend-child--red;
}
&-b {
@extend %extend-child--blue;
}
}
x {
content: "x";
}
y {
content: ".container";
}
.test {
width: 100%;
}
.test-a, .test-b {
font-size: 16px;
}
.test-a {
color: red;
}
.test-b {
color: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment