diff --git a/src/render.rs b/src/render.rs index d95fb6934..0c1e69d3c 100644 --- a/src/render.rs +++ b/src/render.rs @@ -151,11 +151,7 @@ impl Handler for Renderer { fn handle(&mut self, msg: ThreadPage, _: &mut Self::Context) -> Self::Result { let renderable = prepare_thread(&self.comrak, msg); - let mut ctx = Context::new(); - ctx.add("title", &renderable.title); - ctx.add("posts", &renderable.posts); - ctx.add("id", &renderable.id); - Ok(self.tera.render("thread.html", &ctx)?) + Ok(self.tera.render("thread.html", &renderable)?) } } @@ -224,6 +220,7 @@ impl Handler for Renderer { } /// Message used to render search results +#[derive(Serialize)] pub struct SearchResultPage { pub query: String, pub results: Vec, @@ -237,9 +234,6 @@ impl Handler for Renderer { type Result = Result; fn handle(&mut self, msg: SearchResultPage, _: &mut Self::Context) -> Self::Result { - let mut ctx = Context::new(); - ctx.add("query", &msg.query); - ctx.add("results", &msg.results); - Ok(self.tera.render("search.html", &ctx)?) + Ok(self.tera.render("search.html", &msg)?) } }