Unquote empty string is null
This commit is contained in:
parent
3962c4410a
commit
c68a55327b
@ -45,7 +45,7 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
|||||||
decl!(f "unquote", |args, _| {
|
decl!(f "unquote", |args, _| {
|
||||||
max_args!(args, 1);
|
max_args!(args, 1);
|
||||||
match arg!(args, 0, "string").eval() {
|
match arg!(args, 0, "string").eval() {
|
||||||
Value::Ident(i, QuoteKind::None) if i.is_empty() => Ok(Value::Null),
|
Value::Ident(i, _) if i.is_empty() => Ok(Value::Null),
|
||||||
i @ Value::Ident(..) => Ok(i.unquote()),
|
i @ Value::Ident(..) => Ok(i.unquote()),
|
||||||
v => Err(format!("$string: {} is not a string.", v).into()),
|
v => Err(format!("$string: {} is not a string.", v).into()),
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,11 @@ test!(
|
|||||||
"a {\n color: str-length(cde);\n}\n",
|
"a {\n color: str-length(cde);\n}\n",
|
||||||
"a {\n color: 3;\n}\n"
|
"a {\n color: 3;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
unquote_empty_string_is_null,
|
||||||
|
"a {\n color: unquote('');\n}\n",
|
||||||
|
""
|
||||||
|
);
|
||||||
// blocked on refactoring how function-call args are parsed
|
// blocked on refactoring how function-call args are parsed
|
||||||
// right now, whitespace is eaten between idents with no
|
// right now, whitespace is eaten between idents with no
|
||||||
// regard for quotes
|
// regard for quotes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user