aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askama/src/lib.rs4
-rw-r--r--askama_shared/src/input.rs6
2 files changed, 8 insertions, 2 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index b0edb9b..3cf6852 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -33,11 +33,11 @@
//! path is interpreted as relative to the `templates` dir in the directory
//! where the originating crate's `Cargo.toml` resides. In web framework
//! integrations, the path's extension may be used to infer the content type
-//! of the resulting response.
+//! of the resulting response. Cannot be used together with `source`.
//! * `source` (as `source = "{{ foo }}"`): directly sets the template source.
//! This can be useful for test cases or short templates. The generated path
//! is empty, which generally makes it impossible to refer to this template
-//! from other templates.
+//! from other templates. Cannot be used together with `path`.
//! * `print` (as `print = "code"`): enable debugging by printing nothing
//! (`none`), the parsed syntax tree (`ast`), the generated code (`code`)
//! or `all` for both. The requested data will be printed to stdout at
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs
index 43aa400..5fc064b 100644
--- a/askama_shared/src/input.rs
+++ b/askama_shared/src/input.rs
@@ -54,11 +54,17 @@ impl<'a> TemplateMeta<'a> {
if let syn::MetaItem::NameValue(ref key, ref val) = *item {
match key.as_ref() {
"path" => if let syn::Lit::Str(ref s, _) = *val {
+ if source.is_some() {
+ panic!("must specify 'source' or 'path', not both");
+ }
source = Some(Source::Path(s.as_ref()));
} else {
panic!("template path must be string literal");
},
"source" => if let syn::Lit::Str(ref s, _) = *val {
+ if source.is_some() {
+ panic!("must specify 'source' or 'path', not both");
+ }
source = Some(Source::Source(s.as_ref()));
} else {
panic!("template source must be string literal");