variables do not include interpolation

This commit is contained in:
ConnorSkees 2020-03-30 01:48:37 -04:00
parent 52349fb730
commit ae0ce9894c
3 changed files with 9 additions and 4 deletions

View File

@ -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<I: Iterator<Item = Token>>(
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);

View File

@ -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()),
'+' => {

View File

@ -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"
);