]> git.scottworley.com Git - tablify/blobdiff - src/lib.rs
in render_row: name 'cells'
[tablify] / src / lib.rs
index cfaeb4be194b96c5b16faad185e29cbec632b064..357a7eec0afc72411c76398b124c9cf47d16ed76 100644 (file)
@@ -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>();
     HTML(format!(
-        "<tr><th id=\"{row_label}\">{row_label}</th>{}</tr>\n",
-        &columns
-            .iter()
-            .map(|col| render_cell(col, row))
-            .collect::<HTML>()
+        "<tr><th id=\"{row_label}\">{row_label}</th>{cells}</tr>\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#"<tr><th id="nope">nope</th><td class="" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td></tr>
+"#
+            )
+        );
+    }
 }