extern crate hiccup; use hiccup::hiccup; #[test] fn html_templating() { let mut out = String::new(); let _ = hiccup!(&mut out, html[ head[meta{name=>"author", content=>"Julia Naomi"} title["Hiccup guide"]] body{class=>"amazing hiccup guide"}[ h1{font=>"bold", color=>"red"}["Hiccup is the best!"] p["please lookup clojure's hiccup for better ideas on this macro"]] ]); assert_eq!(out,"
\please lookup clojure\'s hiccup for better ideas on this macro
"); } #[test] fn inner_html_templating() { let mut out = String::new(); let _ = hiccup!(&mut out, html[ body{class=>"amazing hiccup guide"}[ h1{font=>"bold", color=>"red"}[bold["Hiccup"] "is the best!"] p["please lookup clojure's hiccup for better ideas on this macro"] p[(format!("{:?}", 3 + 5))]] ]); assert_eq!(out,"please lookup clojure\'s hiccup for better ideas on this macro
\8
"); } #[test] fn remote_code_templating() { let mut out = String::new(); let x = "my str"; let y = "my str2"; let z = "my str3"; let _ = hiccup!(&mut out, html[ body{class=>"amazing hiccup guide"}[ h1{font=>"bold", color=>"red"}[bold["Hiccup"] "is the best!"] p["please lookup clojure's hiccup for better ideas on this macro"] div[ div{hello=>"world"}[(x)] div[(y.to_owned() + " " + z)] ] ] ]); assert_eq!(out,"please lookup clojure\'s hiccup for better ideas on this macro
\please lookup clojure\'s hiccup for better ideas on this macro
\bye
please lookup clojure\'s hiccup for better ideas on this macro
\bye