diff --git a/src/selector.rs b/src/selector.rs index ecf681d..2fc9ac9 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -1,5 +1,7 @@ use crate::common::{Scope, Symbol}; -use crate::utils::{devour_whitespace, devour_whitespace_or_comment, eat_interpolation, IsWhitespace}; +use crate::utils::{ + devour_whitespace, devour_whitespace_or_comment, eat_interpolation, IsWhitespace, +}; use crate::{Token, TokenKind}; use std::fmt::{self, Display}; use std::iter::Peekable; diff --git a/src/utils.rs b/src/utils.rs index efbd6e7..e990b41 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,5 @@ use crate::common::{Pos, Symbol}; +use crate::lexer::Lexer; use crate::value::Value; use crate::{Scope, Token, TokenKind}; use std::iter::{Iterator, Peekable}; @@ -50,10 +51,9 @@ pub(crate) fn eat_interpolation>( TokenKind::Symbol(Symbol::OpenCurlyBrace) => { todo!("invalid character in interpolation") } - TokenKind::Variable(ref v) => val.push(Token { - pos: tok.pos, - kind: TokenKind::Ident(scope.vars.get(v).unwrap().to_string()), - }), + TokenKind::Variable(ref v) => val.extend( + Lexer::new(&scope.vars.get(v).unwrap().to_string()).collect::>(), + ), TokenKind::Interpolation => val.extend(eat_interpolation(tokens, scope)), _ => val.push(tok), } diff --git a/tests/main.rs b/tests/main.rs index ca0c5da..34a6399 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -299,6 +299,11 @@ mod test_selectors { "a /* foo */ b {\n color: red;\n}\n", "a b {\n color: red;\n}\n" ); + test!( + interpolates_comma, + "$x: oo, ba;\nf#{$x}r {\n baz {\n color: red;\n }\n}\n", + "foo baz, bar baz {\n color: red;\n}\n" + ); } #[cfg(test)]