mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
21 lines
434 B
Rust
21 lines
434 B
Rust
#[macro_use]
|
|
extern crate askama;
|
|
extern crate iron;
|
|
|
|
use askama::Template;
|
|
use iron::{status, Response};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "hello.html")]
|
|
struct HelloTemplate<'a> {
|
|
name: &'a str,
|
|
}
|
|
|
|
#[test]
|
|
fn test_iron() {
|
|
let rsp = Response::with((status::Ok, HelloTemplate { name: "world" }));
|
|
let mut buf = Vec::new();
|
|
let _ = rsp.body.unwrap().write_body(&mut buf);
|
|
assert_eq!(buf, b"Hello, world!");
|
|
}
|