X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/5ffe8e3a8394fc46b50659b0e197b0b0a22e18c8..74bd4cd1e2035284040bbaf894c271423b7a5455:/src/lib.rs?ds=sidebyside diff --git a/src/lib.rs b/src/lib.rs index cfaeb4b..357a7ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -226,12 +226,12 @@ fn render_cell(col: &str, row: &mut Row) -> HTML { fn render_row(columns: &[String], row: &mut Row) -> HTML { let row_label = HTML::escape(row.label.as_ref()); + let cells = columns + .iter() + .map(|col| render_cell(col, row)) + .collect::(); HTML(format!( - "{row_label}{}\n", - &columns - .iter() - .map(|col| render_cell(col, row)) - .collect::() + "{row_label}{cells}\n" )) } @@ -551,4 +551,21 @@ mod tests { render_cell("baz", &mut r); assert_eq!(r.entries.len(), 0); } + + #[test] + fn test_render_row() { + assert_eq!( + render_row( + &["foo".to_owned()], + &mut Row { + label: "nope".to_owned(), + entries: HashMap::from([("bar".to_owned(), vec![None])]), + } + ), + HTML::from( + r#"nope +"# + ) + ); + } }