grass/src/utils/interpolation.rs

26 lines
637 B
Rust
Raw Normal View History

use std::iter::Iterator;
use codemap::Spanned;
use peekmore::PeekMoreIterator;
use crate::error::SassResult;
use crate::selector::Selector;
use crate::value::Value;
use crate::{Scope, Token};
use super::read_until_closing_curly_brace;
pub(crate) fn parse_interpolation<I: Iterator<Item = Token>>(
toks: &mut PeekMoreIterator<I>,
scope: &Scope,
super_selector: &Selector,
) -> SassResult<Spanned<Value>> {
let val = Value::from_vec(read_until_closing_curly_brace(toks), scope, super_selector)?;
toks.next();
Ok(Spanned {
node: val.node.eval(val.span)?.node.unquote(),
span: val.span,
})
}