Search code examples
sasshamlslim-langmiddleman

How to get an access to SASS variables in Slim, HAML etc.?


How to get an access to SASS variables & mixins which are stored in the assets directory of project directly from HTML-preprocessors (Slim, HAML)?

I mean how to make work things like this:

// Ruby Slim
style
    sass:
        @import 'lib/vars'
        body
            background: $color

producing:

<style type="text/css">
    body {
        background: #fff
    }
 </style>

whereas $color is defined somewhere in lib/_vars.sass and equals to #fff.

Why do I need it? Well, I need it for page-specific styles and elements and I do not want to store them in global styles.

It doesn't work for me in Middleman+Slim+SASS+Compass environment. Ruby just says:

Error: File to import not found or unreadable: lib/vars.

Solution

  • I wish there was a better answer but, unfortunately, this is not possible.