blob: aa0259dffbb3801bb6aacf32baf2869a81e4e14a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
use self::layout::Layout;
use markup::Render;
use rocket::{
http::ContentType,
response::{self, Responder},
Request, Response,
};
use std::io::Cursor;
pub mod error;
pub mod home;
pub mod layout;
pub mod node;
pub mod style;
pub struct HtmlTemplate<T>(pub String, pub T);
impl<'r, T: Render> Responder<'r, 'static> for HtmlTemplate<T> {
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {
let mut out = String::new();
Layout {
title: self.0,
main: self.1,
}
.render(&mut out)
.unwrap();
Response::build()
.header(ContentType::HTML)
.streamed_body(Cursor::new(out))
.ok()
}
}
|