use std::collections::HashMap; use kitamura::render_template; use serde_json::json; #[test] fn new_line_char_appended_successfully() { let html = " ${first_name} "; let expected_rendered_html = " Joel "; let mut params = HashMap::new(); params.insert("first_name".to_string(), json!("Joel")); let rendered_html = render_template(html.to_string(), params); assert_eq!(rendered_html.unwrap(), expected_rendered_html); } #[test] fn data_mapping_key_is_also_object_in_data() { let html = "{#for person of persons#}${person.first_name}{#endfor#}"; let expected_rendered_html = "Joel"; let mut params = HashMap::new(); params.insert( "persons".to_string(), json!({"persons":[{"first_name": "Joel"}]}), ); let rendered_html = render_template(html.to_string(), params); assert_eq!(rendered_html.unwrap(), expected_rendered_html); }