Include Handlebars Templates for Rocket Framework

Build Status

This is a crate which provides macros handlebars_resources_initialize! and handlebars_response! to statically include HBS (Handlebars) files from your Rust project and make them be the HTTP response sources quickly.

Example

```rust

![feature(plugin)]

![plugin(rocket_codegen)]

[macrouse] extern crate lazystatic;

[macrouse] extern crate lazystatic_include;

[macro_use] extern crate handlebars;

[macrouse] extern crate rocketinclude_handlebars;

extern crate rocket;

use std::collections::HashMap;

use rocketincludehandlebars::{EtagIfNoneMatch, HandlebarsResponse};

handlebarsresourcesinitialize!( "index", "examples/views/index.hbs", "index2", "examples/views/index2.hbs" );

[get("/")]

fn index() -> HandlebarsResponse { let mut map = HashMap::new();

map.insert("title", "Title");
map.insert("body", "Hello, world!");

handlebars_response!("index", &map)

}

[get("/2")]

fn index_2() -> HandlebarsResponse { let mut map = HashMap::new();

map.insert("title", "Title");
map.insert("body", "Hello, world!");

handlebars_response!("index2", &map)

}

[get("/static")]

fn indexstatic() -> HandlebarsResponse { handlebarsresponsestatic!( "index".tostring(), { let mut map = HashMap::new();

        map.insert("title", "Title");
        map.insert("body", "Hello, world!");

        handlebars_response!("index", &map)
    }
)

} ```

In order to reduce the compilation time, files are compiled into your executable binary file together, only when you are using the release profile.

See examples.

Crates.io

https://crates.io/crates/rocket-include-handlebars

Documentation

https://docs.rs/rocket-include-handlebars

License

MIT