Function htmlize::escape_attribute

source ·
pub fn escape_attribute<'a, S: Into<Cow<'a, str>>>(input: S) -> Cow<'a, str>
Expand description

Escape a string to be used in a quoted attribute.

use htmlize::escape_attribute;

assert_eq!(
    escape_attribute(r#"Björk & Борис O'Brien <3, "love > hate""#),
    "Björk &amp; Борис O'Brien &lt;3, &quot;love &gt; hate&quot;"
);

To work with bytes ([u8]) instead of strings, see escape_attribute_bytes().