28 Feb 2011 11:32 AM #1
Quick SASS question re: mixin arguments
I didn't see this addressed in any SASS documentation, so I'll try here.
If you have multiple arguments, is there a way to pass only an argument later than the first without passing the first?
What do you do in SASS to indicate empty arguments?
28 Feb 2011 2:11 PM #2
Can't be done...yet.
Can't be done...yet.
"In Sass 3, there's no way to use the default values for the first arguments to a mixin and a non-default value for later arguments. Sass 3.1, currently in development, supports passing arguments by name, but in 3.0 the best way to do this is just to manually pass in the default values."
- Nathan Weizenbaum
28 Feb 2011 4:49 PM #3
If you do the following:
sudo gem install sass --pre
sudo gem install compass --pre
sudo gem install haml --pre
You can actually do named arguments. We have started to use this a little inside the Ext 4 theme. This is one of the reasons you need the bleeding edge versions of all the gems to be able to compile to Ext 4 theme. You can use named arguments like this:
@include x-frame($border-radius: 10px, $background-gradient: 'matte');
For the rest it would use all the default values.
1 Mar 2011 7:21 AM #4
Thanks for the info, Tommy.
I've only been exploring SASS for a couple days now. It's funny that it doesn't naturally support the very first thing I wanted it to do. It seemed like an obvious thing to do when you have the option to specify default values. It kind of defeats the purpose of using arguments if you need to pass back the default values to get at an argument later in the list.
By alex1001 in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 17 Mar 2010, 5:27 PM
By Litre in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 26 Jan 2010, 11:57 AM
By azuroff in forum Community DiscussionReplies: 1Last Post: 15 Dec 2009, 5:45 PM
By Mthor in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 18 Apr 2008, 11:02 AM
By putty in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 31 Mar 2008, 5:15 PM