Search code examples
sasscompass-sass

Compass Extension equivalent of config.rb


At the end of my Compass config.rb I have a little snippet that generates a random number. This works. And I can get it working when I have the snippet there and the Sass in my projects Sass folder.

I'm trying to create an extension out of this functionality, But I don't know where to put the code so that my mixins in extensions/my-extension/stylesheets/, and hopefully any Sass file that imports the extension have access to it.

I've tried extensions/my-extension/lib/whatever.rb but I'm still getting errors. I've also tried putting the snippet in config.rb, but keeping the mixins/Sass in the extension, but that also doesn't work.

In both of these cases the error I'm getting is that Undefined operation: "random() times 1%".)

Where is the place analogous to the end of the config.rb, but for extensions? Do I need to import it into my extensions' Sass somehow?


Solution

  • Check out this tutorial, particularly the subsection of "Advanced Layout Options" entitled "Library File Location". It lists three different options:

    1. my_extension/compass_init.rb
    2. my_extension/lib/my_extension.rb (NOTE: You must use this one if you're distributing as a rubygem.)
    3. my_extension/my_extension.rb

    Adding your random number function to any of these files should work.