invert if stmt in parsing `@content`
@@ -165,7 +165,14 @@ impl<'a> Parser<'a> {
}
pub(super) fn parse_content_rule(&mut self) -> SassResult<Vec<Stmt>> {
- if self.flags.in_mixin() {
+ if !self.flags.in_mixin() {
+ return Err((
+ "@content is only allowed within mixin declarations.",
+ self.span_before,
+ )
+ .into());
+ }
+
let mut scope = self
.content
.last()
@@ -175,9 +182,7 @@ impl<'a> Parser<'a> {
if let Some(Token { kind: '(', .. }) = self.toks.peek() {
self.toks.next();
let args = self.parse_call_args()?;
- if let Some(Some(content_args)) =
- self.content.last().map(|v| v.content_args.clone())
- {
+ if let Some(Some(content_args)) = self.content.last().map(|v| v.content_args.clone()) {
args.max_args(content_args.len())?;
scope.merge(self.eval_args(content_args, args)?);
@@ -212,12 +217,5 @@ impl<'a> Parser<'a> {
} else {
Vec::new()
})
- } else {
- Err((
- "@content is only allowed within mixin declarations.",
- self.span_before,
- )
- .into())
- }
}
}
