Support variables inside @media identifiers

This solution is somewhat hacky, the @media element really deserves a
Node subclass and it's own parsing rules. What's still missing is LESS
variables in grouped media queries like:

    @singleQuery: ~"(max-width: 500px)";
    @media screen, @singleQuery {
        set { padding: 3 3 3 3; }
    }

Fixes #18
This commit is contained in:
Sascha Peilicke
2013-09-05 14:04:22 +02:00
parent ba8ad98f52
commit 11895c7e30
4 changed files with 19 additions and 0 deletions

View File

@@ -514,6 +514,14 @@ class LessParser(object):
"""
p[0] = list(p)[1:]
def p_ident_media_var(self, p):
""" ident_parts : css_media t_ws t_popen word ':' variable t_pclose
"""
p[0] = list(p)[1:]
if utility.is_variable(p[0][5]):
var = self.scope.variables(''.join(p[0][5]))
p[0][5] = var.value[0]
def p_selector(self, p):
""" selector : '*'
| '+'

View File

@@ -34,3 +34,8 @@
display: none !important;
}
}
@media (min-width:12px) {
body {
margin: 0 auto;
}
}

View File

@@ -6,3 +6,4 @@ body{max-width:35em;margin:0 auto;}}
@media screen{body{max-width:480;}}
@media all and (orientation:portrait){aside{float:none;}}
@media (min-width:768px)and (max-width: 979px){.hidden-desktop{display:none !important;}}
@media (min-width:12px){body{margin:0 auto;}}

View File

@@ -42,3 +42,8 @@
@media (min-width: 768px) and (max-width: 979px) {
.hidden-desktop { display: none !important; }
}
@minwidth: 12px;
@media (min-width: @minwidth) {
body { margin: 0 auto; }
}