.box {
&-title {
...
}
}
...
// hoge ページ
.hoge {
.box {
@include box-base;
}
}
// fuga ページ
.fuga {
.box {
...
}
}
_box.scss
@mixin box-base {
$target: unquote("#{&}");
@if str-index($target, ' ') == null {
} @else {
$target: str-slice($target, str-index($root, ' ') + 1, str-length($target));
}
&-title {
...
}
// ここで `.box-title` を取りたい
@each $category in $categories {
&.#{$category} {
#{$target}-title {
background-image: url(#{$category}_title_bg.gif);
}
}
}
}
とりあえずネストは1つしか考慮してない。