Access compass env inside Sass file

As far as I can tell I need to set the compass environment by hand inside my config.rb.

compass_config do |config|
  config.environment = environment
end

Now I’d like to access that variable inside my stylesheets to conditionally add development styles.

@import 'susy';
@if compass-env() == 'development' {
  .foo { @include susy-grid-background; }
}

I guess that should do it, but I end up getting a NoMethodError: undefined method []' for nil:NilClass inside compass-0.12.2/lib/compass/sass_extensions/functions/env.rb

// I’m using Haml’s SCSS filter as a workaround for now …

If you need access to the Middleman environment, you could renamed your file to include erb like style.css.scss.erb and use Erb inside it:

<% if development? %>
  .foo { @include susy-grid-background; }
<% end %>

I have just added a couple more use cases on the following thread if it’s any help: Pass erb from partials into sass (file)?.

I don’t know what the feasibility is, but if templating could be integrated into SASS the way it is for the rest of the file types (so you could have partials in any templating language and import them) that would be amazingly powerful.