use mustache::{Template, compile_str};
use model::Cocktail;
pub const HEADER_IMAGE: &'static [u8] =
include_bytes!("../static/header-logo.png");
lazy_static! {
static ref MAIN_TEMPLATE: Template =
compile_str(include_str!("../template/main.mustache")).unwrap();
static ref COCKTAILS_TEMPLATE: Template =
compile_str(include_str!("../template/cocktails.mustache")).unwrap();
}
#[derive(RustcEncodable)]
struct MainContent {
content: String,
og_data: Option<()>,
}
pub fn render_main(content: String, og_data: Option<()>) ->
Result<String, ::mustache::Error>
{
MAIN_TEMPLATE.render_to_string(&MainContent {
content, og_data
})
}
#[derive(RustcEncodable)]
struct CocktailList {
cocktail: Vec<Cocktail>,
}
pub fn render_cocktails(cocktails: Vec<Cocktail>) -> Result<String, ::mustache::Error> {
let content = COCKTAILS_TEMPLATE.render_to_string(&CocktailList { cocktail: cocktails })?;
render_main(content, None)
}