1

I have a home grown CSS framework that sometimes has to be included on pages that already have other HTML/CSS. To avoid CSS conflicts I'd like to put a parent ID selector in front of everything so that the CSS is generated like this: #MyFramework .thing-one { /* styles */ }. But I'd like this to be optional and set via a varialbe. So I came up with the following, but it doesn't work but doesn't produce any Sass errors either. Is there a correct way to do this?

$framework-wrap: true;

@if $framework-wrap {
    #MyFramework {
}
        @import 'component-one';
        @import 'component-two';
        @import 'component-three';

@if $framework-wrap {
    }
}
Ben
  • 2,917
  • 10
  • 28
  • 47
  • possible duplicate of [@import in @if statement in SASS](http://stackoverflow.com/questions/13879042/import-in-if-statement-in-sass) – cimmanon Oct 02 '14 at 01:06
  • @cimmanon It's not a duplicate. I'm asking if there is a way to write part of a single statement in an if, then finish that statement later on in another if. – Ben Oct 02 '14 at 01:31
  • The answer is still the same: No, that's not possible (though the reason is different), and the solution given is your only option. – cimmanon Oct 02 '14 at 03:00
  • @cimmanon which of the three answers (none of which are marked as the accepted answer" would you say it "correct"? So that I can understand the "why its not possible" better? Thanks. – Ben Oct 02 '14 at 12:47

0 Answers0