pub fn phoenix_html_label(label: &String, option_id: Option<usize>) -> String{
if label.is_empty() {
return String::from("");
}
let extra_id: String = match option_id {
Some(id) => String::from(format!("<b>({})</b>", id)),
None => String::from("")
};
let mut body = String::from(r#"<span class="redirectIcon"><a href="redirection.html?label="#);
body += &label;
body += &String::from(r#"">"#);
body += &extra_id;
body += &String::from(r#"<img src="book/images/iconlink_32.png"></a></span>"#);
return body;
}
#[cfg(test)]
mod tests{
use super::*;
#[test]
fn test_phoenix_html_label(){
assert_eq!(phoenix_html_label(&String::from("secFirstPerformanceTestTimerH"), None), String::from(r#"<span class="redirectIcon"><a href="redirection.html?label=secFirstPerformanceTestTimerH"><img src="book/images/iconlink_32.png"></a></span>"#));
assert_eq!(phoenix_html_label(&String::from("secFirstPerformanceTestTimerH"), Some(42)), String::from(r#"<span class="redirectIcon"><a href="redirection.html?label=secFirstPerformanceTestTimerH"><b>(42)</b><img src="book/images/iconlink_32.png"></a></span>"#));
}
}