rshtml_core 0.4.0

RsHtml: A Template Engine for Seamless HTML and Rust Integration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub(crate) trait IsEscaped {
    fn is_escaped(&self) -> bool;
    fn escaped_or_raw(&self) -> String;
}

impl<T: AsRef<str>> IsEscaped for T {
    fn is_escaped(&self) -> bool {
        !self.as_ref().starts_with("#")
    }

    fn escaped_or_raw(&self) -> String {
        if self.is_escaped() {
            return self.as_ref().to_string();
        }

        self.as_ref().chars().skip(1).collect()
    }
}