Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Latest commit

 

History

History
35 lines (24 loc) · 825 Bytes

README.md

File metadata and controls

35 lines (24 loc) · 825 Bytes

iron-liquid

Bring liquid template to Iron : https://github.com/iron/iron

Use liquid : https://github.com/FerarDuanSednan/liquid-rust.git

Inspired by https://github.com/sunng87/handlebars-iron.git

#Example

use liquid::Value;
use std::default::Default;

/// the handler
fn hello_world(_req: &mut Request) -> IronResult<Response> {
    let mut resp = Response::new();

    let data : HashMap<String, Value> = make_data();
    resp.set_mut(Template::new("index", data)).set_mut(status::Ok);
    Ok(resp)
}

fn main() {
    env_logger::init().unwrap();

    let mut chain = Chain::new(hello_world);
    let muse = LiquidEngine::new("./examples", Default::default());

    chain.link_after(muse);
    println!("Server running at http://localhost:3000/");
    Iron::new(chain).http("localhost:3000").unwrap();
}