lambda-fairy / maud

:pencil: Compile-time HTML templates for Rust
https://maud.lambda.xyz
Apache License 2.0
2.09k stars 137 forks source link

Remove blanket `Render` impl for `T: Display` #320

Closed lambda-fairy closed 2 years ago

lambda-fairy commented 2 years ago

Closes #271

How to migrate

If you have code that uses a Display impl, like so:

let ip_address = Ipv4Addr::new(127, 0, 0, 1);
html! {
    "There's no place like " (ip_address)
}

Then change it to use maud::display (#350):

let ip_address = Ipv4Addr::new(127, 0, 0, 1);
html! {
    "There's no place like " (maud::display(ip_address))
}
lambda-fairy commented 2 years ago
lambda-fairy commented 2 years ago

miniserve needs this patch:

diff --git a/src/renderer.rs b/src/renderer.rs
index ba2c4e6..72ff602 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -423,7 +423,7 @@ fn entry_row(
                         @if !raw {
                             @if let Some(size) = entry.size {
                                 span.mobile-info.size {
-                                    (size)
+                                    (maud::display(size))
                                 }
                             }
                         }
@@ -432,7 +432,7 @@ fn entry_row(
             }
             td.size-cell {
                 @if let Some(size) = entry.size {
-                    (size)
+                    (maud::display(size))
                 }
             }
             td.date-cell {