Skip to main content

html_escape

Function html_escape 

Source
pub fn html_escape(s: &str) -> String
Expand description

Escape a string for safe insertion into HTML element content or double-quoted HTML attributes.

Replaces &, <, >, ", ' with their HTML entities.

ยงExample

use rustango::text::html_escape;
assert_eq!(html_escape("<script>"), "&lt;script&gt;");
assert_eq!(html_escape("a & b"), "a &amp; b");