diff options
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/posts_controller.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/controllers/posts_controller.rs b/src/controllers/posts_controller.rs index 47f9ca1..aca9d13 100644 --- a/src/controllers/posts_controller.rs +++ b/src/controllers/posts_controller.rs @@ -1,3 +1,4 @@ +use comrak::{markdown_to_html, ComrakOptions}; use rocket::request::Form; use rocket::response::{Flash, Redirect}; use utils; @@ -35,6 +36,12 @@ pub struct ShowPostTemplate { implement_responder_for!(ShowPostTemplate); +impl ShowPostTemplate { + pub fn rendered_body(&self) -> String { + markdown_to_html(&self.post.body, &ComrakOptions::default()) + } +} + #[get("/<id>", format = "text/html")] fn show(id: i32, conn: utils::DbConn) -> utils::Page<ShowPostTemplate> { let p = ::models::Post::get(id, conn); |