From ae0ce9894ca672cc32ec28c3fc1aaa1cb94dfdc6 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 30 Mar 2020 01:48:37 -0400 Subject: [PATCH] variables do not include interpolation --- src/lib.rs | 4 ++-- src/value/parse.rs | 4 ++-- tests/variables.rs | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fd315ec..2638ca9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,7 +97,7 @@ use crate::style::Style; pub(crate) use crate::token::Token; use crate::utils::{ devour_whitespace, eat_comment, eat_ident, eat_variable_value, parse_quoted_string, - read_until_newline, VariableDecl, + read_until_newline, VariableDecl, eat_ident_no_interpolation }; use crate::value::Value; @@ -530,7 +530,7 @@ pub(crate) fn eat_expr>( values.push(toks.next().unwrap()); continue; } - let name = eat_ident(toks, scope, super_selector)?; + let name = eat_ident_no_interpolation(toks)?; if toks.peek().unwrap().kind == ':' { toks.next(); devour_whitespace(toks); diff --git a/src/value/parse.rs b/src/value/parse.rs index a4fdaa9..3a35ba4 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -15,7 +15,7 @@ use crate::selector::Selector; use crate::unit::Unit; use crate::utils::{ devour_whitespace, eat_comment, eat_ident, eat_number, parse_interpolation, - parse_quoted_string, read_until_newline, + parse_quoted_string, read_until_newline, eat_ident_no_interpolation }; use crate::value::Value; use crate::Token; @@ -465,7 +465,7 @@ impl Value { } '$' => { toks.next(); - Ok(scope.get_var(&eat_ident(toks, scope, super_selector)?)?) + Ok(scope.get_var(&eat_ident_no_interpolation(toks)?)?) } '@' => Err("expected \";\".".into()), '+' => { diff --git a/tests/variables.rs b/tests/variables.rs index 3d53898..0317efd 100644 --- a/tests/variables.rs +++ b/tests/variables.rs @@ -103,3 +103,8 @@ test!( // "$vär: foo;\na {\n color: $vär;\n}\n", // "a {\n color: foo;\n}\n" // ); +test!( + variable_does_not_include_interpolation, + "$input: foo;\na {\n color: $input#{\"literal\"};\n}\n", + "a {\n color: foo literal;\n}\n" +);