$x: true;

@mixin foobar() {
  @if $x {
    $x: false !global;
    content: foo;
  }
  @else {
    $x: true !global;
    content: bar;
  }
}

div {
  @include foobar();
  @include foobar();
  @include foobar();
  $x: true !global;
  @include foobar();
}
