Wednesday, February 23, 2011

@def in @if for Conditional CSS

Is there a way to get @def statments to get work in @if statments.
Whenever I try this, the @def last @if statment wins.For example:

@def backgroundColor #e00;

@if platform p1{
@def backgroundColor #F1C1BD;
}
@if platform p2{
@def backgroundColor #FDDCC5;
}
@if platform p3{
@def backgroundColor #F7C2DB;
}

backgroundColor is always #F7C2DB. The only way I've got it work is to
have explicit css rules in the if statement, which isn't very elegant:

@if platform p1 {
body {
background: #F1C1BD;
}
}

@if platform p2 {
body {
background: #FDDCC5;
}
}

@if platform p3 {
body {
background: #F7C2DB;
}
}

The documentation says it should work, but isn't very helpfully btw:

What does it mean to have an @def or @eval in an @if block? Easy to
make this work for property-based @if statements; would have to
generate pretty gnarly runtime code to handle the expression-based @if
statement. Could have block-level scoping; but this seems like a
dubious use-case

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

No comments:

Post a Comment