I'm trying this and it won't work. Am I just trying to dynamically 
construct variables a different way?

$team: cardinals;

$base-color: gray;
$base-color: if($team == cardinals, red, gray);
$base-color: if($team == cubs, blue, gray)

On Thursday, April 14, 2011 9:41:16 AM UTC-5, Chris Eppstein wrote:
>
> You cannot dynamically construct variables. In sass 3.1 there's a new 
> function called `if` so you can do this:
>
> width: if($orientation == portrait, $portrait_width, $landscape_width);
>
> chris
>
> On Thu, Apr 14, 2011 at 1:32 AM, Victor Nystad <vny...@gmail.com<javascript:>
> > wrote:
>
>> I'm writing a mixin for a grid for an iPad app, where the orientation of 
>> the iPad determines the property values. 
>> To avoid unnecessary repetition I'd like to use dynamic variable names.
>>
>> Lets say I have two variables: 
>>
>> $portrait_width: 600px;
>> $landscape_width: 900px;
>>
>> And then the mixin:
>>
>> @mixin grid($orientation) {
>>     .#{$orientation} {
>>         width:  #{'$' + (#{$orientation}_width)};
>>     }
>> }
>>
>> Usage: 
>>
>> @include grid(portrait);
>> @include grid(landscape);
>>
>> This simply outputs the variable name and not the value:
>>
>> .portrait {
>>   width: $portrait_width;
>> }
>>
>> .landscape {
>>   width: $landscape_width;
>> }
>>
>> I've tried all the combinations I can think of in the mixin, but can't 
>> get this to work. 
>> Is this possible at all?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Haml" group.
>> To post to this group, send email to ha...@googlegroups.com <javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> haml+uns...@googlegroups.com <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/haml?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to haml+unsubscr...@googlegroups.com.
To post to this group, send email to haml@googlegroups.com.
Visit this group at http://groups.google.com/group/haml.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to