#[macro_export]
macro_rules! tera_resources_initialize {
( $tera:expr, $($name:expr => $path:expr), * $(,)* ) => {
{
use ::std::fs;
use ::std::collections::HashSet;
let mut set: HashSet<&str> = HashSet::new();
$(
if set.contains($name) {
panic!("The name `{}` is duplicated.", $name);
} else {
$tera.add_raw_template($name, include_str!($crate::manifest_dir_macros::path!($path))).unwrap();
set.insert($name);
}
)*
}
};
}
#[macro_export]
macro_rules! tera_response_cache {
($cm:expr, $etag_if_none_match:expr, $key:expr, $gen:block) => {
match $cm.build_from_cache(&$etag_if_none_match, &$key) {
Some(res) => res,
None => {
let res = $gen;
match res.into_html_and_etag() {
Some((content, etag)) => {
let res = $crate::TeraResponse::build_cache(content.clone(), &etag);
$cm.insert($key, (content, ::std::sync::Arc::new(etag)));
res
}
None => $crate::TeraResponse::not_modified(),
}
}
}
};
}