A simple and stupid question, yet I dont know how to answer it

12 views
Skip to first unread message

Martin Bavio

unread,
Feb 1, 2012, 1:03:05 PM2/1/12
to compas...@googlegroups.com
Hey guys, I'm starting to know how partials are amazing for my app. The thing is that I have multiple partials, and I want to use Compass in all of them. What's the best way of doing this? Do I have to include compass in all the partials to make this work?

Best regards,

Martin Bavio

 

Break on Through.


Contact me: Google Talk mbavio Skype mbavio123

Chris Eppstein

unread,
Feb 1, 2012, 1:54:39 PM2/1/12
to compas...@googlegroups.com
For performance I do all my third-party imports (compass, extensions, etc) via a partial at the start of my non-partial stylesheets and the partials just assume they will be in scope.

For correctness/robustness, you would import from file that has the dependency.

Chris

Martin Bavio

unread,
Feb 1, 2012, 2:27:18 PM2/1/12
to compas...@googlegroups.com
Chris, thanks for your answer. I'm not sure I fully understand what you mean, so I'm gonna present a simple example and see what do you think...

I have a _base.scss partial from where I import Compass and some other extensions like Susy. Then I have my main stylesheet called application.css.scss (yeah, I'm on Rails) from where I import _base.scss. Now, the problem starts when I create a new partial (let's call it _header.scss) and import them from application.css.scss.

If I try to use any of the Compass mixings in application.css.scss, it works just fine, but if I do the same in the other partial (_header.scss in this example) it throws me an error about that mixin not existing.

So, right now I see only two solutions: not use partials at all and just write all the code in application.css.scss or include _base.scss in all the other partials too. Is there a better way of solving this problem? If I include _base.scss twice, it gets written twice in the final css code?


Best regards,

Martin Bavio

 

Break on Through.


Contact me: Google Talk mbavio Skype mbavio123


--
You received this message because you are subscribed to the Google Groups "Compass" group.
To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compass-users?hl=en.

Chris Eppstein

unread,
Feb 1, 2012, 2:34:41 PM2/1/12
to compas...@googlegroups.com
On Wed, Feb 1, 2012 at 11:27 AM, Martin Bavio <mba...@gmail.com> wrote:
If I try to use any of the Compass mixings in application.css.scss, it works just fine, but if I do the same in the other partial (_header.scss in this example) it throws me an error about that mixin not existing.

If _header is imported after _base then it should be able to access all the imports and variables in _base. If this doesn't work, there's a bug or user error happening.

chris

Peter Gumeson

unread,
Feb 1, 2012, 2:56:10 PM2/1/12
to compas...@googlegroups.com
Actually, from my experience I seem to remember needing to do all your imports at the top of application.css.scss and not inside of _base.scss to make them visible in subsequent partials.  But I have not tested in most recent versions of compass.

Another solution would be to import _base inside of each partial instead of in application, but that's probably not what you want.

Peter

Martin Bavio

unread,
Feb 1, 2012, 3:35:48 PM2/1/12
to compas...@googlegroups.com
Seems like I was doing something very wrong, because I tested again (calling for compass mixins from a third partial) and it works like charm. Thanks Chris, and Peter, seems like it's been updated since last time you checked.

By the way, besides SMACSS, is there any other documentation about the best way of organizing styles (I know you had written an article, Chris, I already have it in my bookmarks).

Thanks, guys, Compass community rocks!


Best regards,

Martin Bavio

 

Break on Through.


Contact me: Google Talk mbavio Skype mbavio123


--
You received this message because you are subscribed to the Google Groups "Compass" group.
To view this discussion on the web visit https://groups.google.com/d/msg/compass-users/-/uCoieGwE-HsJ.

Mike Fowler

unread,
Feb 1, 2012, 1:35:57 PM2/1/12
to Compass
You are correct. The Compass imports are just mixins, so you're not
actually including any additional code unless you use those mixins.

Include whichever Compass modules you need in whichever partials you
need them in and you'll be all set.
Reply all
Reply to author
Forward
0 new messages