grass/src/style.rs

32 lines
719 B
Rust
Raw Normal View History

2020-06-16 19:38:30 -04:00
use codemap::Spanned;
2020-04-12 19:37:12 -04:00
2020-02-16 10:54:25 -05:00
use crate::error::SassResult;
use crate::value::Value;
/// A style: `color: red`
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct Style {
pub property: String,
2020-04-12 19:37:12 -04:00
pub value: Spanned<Value>,
}
impl Style {
2020-04-12 19:37:12 -04:00
pub fn to_string(&self) -> SassResult<String> {
Ok(format!(
"{}: {};",
self.property,
self.value.node.to_css_string(self.value.span)?
))
}
pub(crate) fn eval(self) -> SassResult<Self> {
Ok(Style {
property: self.property,
value: Spanned {
span: self.value.span,
node: self.value.node.eval(self.value.span)?.node,
},
})
}
}