allow control flow inside @content
This commit is contained in:
parent
c4de587f4e
commit
cfa734e412
@ -4,7 +4,7 @@ use codemap::Spanned;
|
|||||||
|
|
||||||
use peekmore::{PeekMore, PeekMoreIterator};
|
use peekmore::{PeekMore, PeekMoreIterator};
|
||||||
|
|
||||||
use super::eat_stmts;
|
use super::ruleset_eval;
|
||||||
|
|
||||||
use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs};
|
use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs};
|
||||||
use crate::atrule::AtRule;
|
use crate::atrule::AtRule;
|
||||||
@ -223,18 +223,28 @@ pub(crate) fn eat_include<I: Iterator<Item = Token>>(
|
|||||||
|
|
||||||
devour_whitespace(toks);
|
devour_whitespace(toks);
|
||||||
|
|
||||||
let content = if let Some(tok) = toks.peek() {
|
let mut content = Vec::new();
|
||||||
|
|
||||||
|
if let Some(tok) = toks.peek() {
|
||||||
if tok.kind == '{' {
|
if tok.kind == '{' {
|
||||||
toks.next();
|
toks.next();
|
||||||
eat_stmts(toks, &mut scope.clone(), super_selector, false)?
|
ruleset_eval(
|
||||||
|
toks,
|
||||||
|
&mut scope.clone(),
|
||||||
|
super_selector,
|
||||||
|
false,
|
||||||
|
&mut content,
|
||||||
|
)?;
|
||||||
} else if has_content {
|
} else if has_content {
|
||||||
eat_stmts(toks, &mut scope.clone(), super_selector, false)?
|
ruleset_eval(
|
||||||
} else {
|
toks,
|
||||||
Vec::new()
|
&mut scope.clone(),
|
||||||
|
super_selector,
|
||||||
|
false,
|
||||||
|
&mut content,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Vec::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
let mixin = scope.get_mixin(name)?;
|
let mixin = scope.get_mixin(name)?;
|
||||||
|
|
||||||
|
@ -199,3 +199,8 @@ test!(
|
|||||||
"@mixin foo($a_b) {\n color: $a-b;\n color: $a_b;\n}\na {\n @include foo($a_b: a);\n @include foo($a-b: a);\n}\n",
|
"@mixin foo($a_b) {\n color: $a-b;\n color: $a_b;\n}\na {\n @include foo($a_b: a);\n @include foo($a-b: a);\n}\n",
|
||||||
"a {\n color: a;\n color: a;\n color: a;\n color: a;\n}\n"
|
"a {\n color: a;\n color: a;\n color: a;\n color: a;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
control_flow_in_content,
|
||||||
|
"@mixin foo {\n @content;\n}\n\na {\n @include foo {@if true {color: red;}}\n}\n",
|
||||||
|
"a {\n color: red;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user