]> git.scottworley.com Git - tablify/commitdiff
Don't emit useless `class=""`
authorScott Worley <scottworley@scottworley.com>
Sat, 5 Oct 2024 01:49:27 +0000 (18:49 -0700)
committerScott Worley <scottworley@scottworley.com>
Sat, 5 Oct 2024 01:49:27 +0000 (18:49 -0700)
src/lib.rs

index 859b3c19157d11b1e003165bbc7a72249641fc62..d85de02dda58b9cbbe1d077d5bd485851d255946 100644 (file)
@@ -322,14 +322,14 @@ fn render_cell(col: &str, row: &mut Row) -> HTML {
             Some(content) => content == "×",
         }),
     };
-    let class = HTML::from(if is_empty { "" } else { "yes" });
+    let class = HTML::from(if is_empty { "" } else { r#" class="yes""# });
     let contents = match instances {
         None => HTML::from(""),
         Some(is) => render_instances(is),
     };
     row.entries.remove(col);
     HTML(format!(
-        r#"<td class="{class}" onmouseover="h2('{row_label}','{col_label}')" onmouseout="ch2('{row_label}','{col_label}')">{contents}</td>"#
+        r#"<td{class} onmouseover="h2('{row_label}','{col_label}')" onmouseout="ch2('{row_label}','{col_label}')">{contents}</td>"#
     ))
 }
 
@@ -697,7 +697,7 @@ mod tests {
                 }
             ),
             HTML::from(
-                r#"<td class="" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
+                r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
             )
         );
         assert_eq!(
@@ -709,7 +709,7 @@ mod tests {
                 }
             ),
             HTML::from(
-                r#"<td class="" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
+                r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
             )
         );
         assert_eq!(
@@ -772,7 +772,7 @@ mod tests {
                 }
             ),
             HTML::from(
-                r#"<td class="" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">×</td>"#
+                r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">×</td>"#
             )
         );
         assert_eq!(
@@ -882,7 +882,7 @@ mod tests {
                 })
             ),
             HTML::from(
-                r#"<tr><th id="nope">nope</th><td class="" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')">bar</td></tr>
+                r#"<tr><th id="nope">nope</th><td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')">bar</td></tr>
 "#
             )
         );