mirror of https://github.com/rwf2/Rocket.git
Require commas in template macros.
This commit is contained in:
parent
084a9125fa
commit
f088459621
|
@ -1,6 +1,6 @@
|
|||
#[macro_export]
|
||||
macro_rules! engine_set {
|
||||
($($feature:expr => $engine:ident),+) => ({
|
||||
($($feature:expr => $engine:ident),+,) => ({
|
||||
use std::collections::HashSet;
|
||||
let mut set = HashSet::new();
|
||||
$(
|
||||
|
@ -20,7 +20,7 @@ macro_rules! engine_set {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! render_set {
|
||||
($name:expr, $info:expr, $ctxt:expr, $($feature:expr => $engine:ident),+) => ({$(
|
||||
($name:expr, $info:expr, $ctxt:expr, $($feature:expr => $engine:ident),+,) => ({$(
|
||||
#[cfg(feature = $feature)]
|
||||
fn $engine<T: Serialize>(name: &str, info: &TemplateInfo, c: &T)
|
||||
-> Option<Template> {
|
||||
|
|
|
@ -20,6 +20,7 @@ use self::glob::glob;
|
|||
|
||||
lazy_static! {
|
||||
static ref TEMPLATES: HashMap<String, TemplateInfo> = discover_templates();
|
||||
// FIXME: Ensure template_dir is an absolute path starting at crate root.
|
||||
static ref TEMPLATE_DIR: String =
|
||||
Rocket::config("template_dir").unwrap_or("templates").to_string();
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ fn discover_templates() -> HashMap<String, TemplateInfo> {
|
|||
// Keep this set in-sync with the `render_set` invocation.
|
||||
let engines = engine_set![
|
||||
"tera_templates" => tera_templates,
|
||||
"handlebars_templates" => handlebars_templates
|
||||
"handlebars_templates" => handlebars_templates,
|
||||
];
|
||||
|
||||
let mut templates = HashMap::new();
|
||||
|
@ -83,7 +84,7 @@ impl Template {
|
|||
// Keep this set in-sync with the `engine_set` invocation.
|
||||
render_set!(name, template.unwrap(), context,
|
||||
"tera_templates" => tera_templates,
|
||||
"handlebars_templates" => handlebars_templates
|
||||
"handlebars_templates" => handlebars_templates,
|
||||
);
|
||||
|
||||
unreachable!("A template extension was discovered but not rendered.")
|
||||
|
|
|
@ -5,10 +5,10 @@ extern crate rocket;
|
|||
use rocket::Rocket;
|
||||
|
||||
#[get("/")]
|
||||
fn root() -> &'static str {
|
||||
fn hello() -> &'static str {
|
||||
"Hello, world!"
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Rocket::new("localhost", 8000).mount_and_launch("/", routes![root]);
|
||||
Rocket::new("localhost", 8000).mount_and_launch("/hello", routes![hello]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue