#[macro_export]
macro_rules! handlebars_resources_initialize {
( $handlebars:expr, $(,)* ) => {{}};
( $handlebars:expr, $($name:expr => $path:expr),+ $(,)* ) => {{
let mut names = ::std::collections::HashSet::new();
$(
let name: &'static str = $name;
if !names.insert(name) {
panic!("The name `{}` is duplicated.", name);
}
$handlebars.register_template_string(name, include_str!($crate::manifest_dir_macros::path!($path))).unwrap();
)+
}};
}
#[macro_export]
macro_rules! handlebars_response_cache {
($cm:expr, $etag_if_none_match:expr, $key:expr, $gen:block) => {{
let cm = &$cm;
let etag_if_none_match: &$crate::EtagIfNoneMatch<'_> = &$etag_if_none_match;
let key = &$key;
let key = ::std::convert::AsRef::<str>::as_ref(key);
match cm.build_from_cache(etag_if_none_match, key) {
Some(res) => res,
None => {
let key = ::std::borrow::ToOwned::to_owned(key);
let etag_if_none_match = ::std::clone::Clone::clone(etag_if_none_match);
let res = $gen;
match res.into_cache_parts() {
Ok((content, etag)) => {
let res = if etag_if_none_match.weak_eq(&etag) {
$crate::HandlebarsResponse::not_modified_with_etag(&etag)
} else {
$crate::HandlebarsResponse::build_cache(content.clone(), etag.clone())
};
$cm.insert(key, (content, etag));
res
},
Err(res) => res,
}
},
}
}};
}