[][src]Function htmlentity::entity::encode_with

pub fn encode_with<F>(content: &str, encoder: F) -> String where
    F: Fn(char) -> Option<EncodeType>, 

encode with the Encoder function.

Examples

use htmlentity::entity::*;

let html = "<div class='header'></div>";
let html_encoded = encode_with(html, |ch:char|{
  if(EntitySet::SpecialChars.contains(&ch)){
    return Some(EncodeType::Named);
  }
  None
});
assert_eq!(html_encoded, "&lt;div class=&apos;header&apos;&gt;&lt;/div&gt;");

let html_decoded = decode(&html_encoded);