Verify that mixin is being called from within a media query

Multi tool use


Verify that mixin is being called from within a media query
I need to do a check in a mixin, to know if it's being called from within a media query. It's possible?
@mixin test {
@if [is within a media query?] {
...
} @else {
...
}
}
@media (min-width: 768px) {
@include test;
}
1 Answer
1
You could use the @debug (<= 3.3) or @error (>=3.4) to output to the console from within the mixin to check if it has been compiled (this would assume you can isolate the usage of the mixin to this media query for this test). There isn't a way to use @if in Sass as you are asking about.
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#error
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.