diff options
author | Vincent Ambo <mail@tazj.in> | 2018-05-22T17·34+0200 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2018-05-22T18·44+0200 |
commit | 4747bacfe9502bfd1aca14ffe0c4e9b5b3b86753 (patch) | |
tree | db6bad669f59852f279cf01316326995ee90df04 | |
parent | 2bbcced032937240ac6fb3f1cfe5136d421b3bea (diff) |
refactor(templates): Move search result template to Askama
-rw-r--r-- | src/render.rs | 5 | ||||
-rw-r--r-- | templates/search.html | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/render.rs b/src/render.rs index d0852fa3959a..ea198c31de3a 100644 --- a/src/render.rs +++ b/src/render.rs @@ -246,7 +246,8 @@ impl Handler<EditPostPage> for Renderer { } /// Message used to render search results -#[derive(Serialize)] +#[derive(Template)] +#[template(path = "search.html")] pub struct SearchResultPage { pub query: String, pub results: Vec<SearchResult>, @@ -257,6 +258,6 @@ impl Handler<SearchResultPage> for Renderer { type Result = Result<String>; fn handle(&mut self, msg: SearchResultPage, _: &mut Self::Context) -> Self::Result { - Ok(self.tera.render("search.html", &msg)?) + msg.render().map_err(|e| e.into()) } } diff --git a/templates/search.html b/templates/search.html index 0ff49e508d52..a74b60e0a715 100644 --- a/templates/search.html +++ b/templates/search.html @@ -44,7 +44,7 @@ <div class="mdl-card mdl-cell--6-col search-result mdl-shadow--2dp"> <div class="mdl-card__supporting-text"> <p>Posted in '{{ result.title }}' by {{ result.author }}:</p> - <p>{{ result.headline | safe }}</p> + <p>{{ result.headline|safe }}</p> </div> <div class="mdl-card__actions mdl-card--border post-actions"> <div class="mdl-layout-spacer"></div> |