refactor(v0): render todos through heml template

Remove the hand-written push_str renderer for the v0 todos view so the canonical beginner example uses its .heml template for the whole page path, including form validation targets, notices, and keyed rows.

req: examples/001

req: canonical_authoring/003
This commit is contained in:
slhx agent
2026-06-22 22:39:47 +02:00
parent de6ecd469f
commit f1d84e4837
+1 -19
View File
@@ -123,31 +123,13 @@ impl IntoHandlerFailure for AppError {
}
}
#[derive(Hemplate)]
struct Todos {
summary: String,
notice: String,
rows: Vec<TodoRow>,
}
impl Hemplate for Todos {
fn render_into(&self, buf: &mut String) -> Result<(), hemplate::error::HemplateError> {
use std::fmt::Write as _;
buf.push_str("<section data-hemx-root=\"todos\">\n <form data-hemx-handle=\"add_todo\" data-hemx-form=\"new_todo\">\n <label>New todo\n <input name=\"title\" required=\"required\">\n </label>\n <button type=\"submit\">Add</button>\n <p data-hemx-error-for=\"title\"></p>\n </form>\n\n <p data-hemx-error role=\"status\" hidden=\"hidden\"></p>\n\n <p data-hemx-slot=\"summary\">");
write!(buf, "{}", hemplate::HtmlEscape(&self.summary))?;
buf.push_str("</p>\n <p data-hemx-slot=\"notice\">");
write!(buf, "{}", hemplate::HtmlEscape(&self.notice))?;
buf.push_str("</p>\n\n <ul data-hemx-slot=\"todo_row\">\n");
for row in &self.rows {
buf.push_str(" ");
row.render_into(buf)?;
buf.push('\n');
}
buf.push_str(" </ul>\n</section>\n");
Ok(())
}
}
#[derive(Hemplate)]
#[hemplate = "partials"]
struct TodoRow {