diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-06 20:03:22 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-06 20:03:47 +0200 |
commit | ddcc0453ba8803ba8f15eb1de030cd5f96731ed5 (patch) | |
tree | fadc5bb629061004a49d7d3ca60a7fbc80e0a448 | |
parent | 09514f07ee1a649281e5b41015b99235309416ea (diff) | |
download | askama-ddcc0453ba8803ba8f15eb1de030cd5f96731ed5.tar.gz askama-ddcc0453ba8803ba8f15eb1de030cd5f96731ed5.tar.bz2 askama-ddcc0453ba8803ba8f15eb1de030cd5f96731ed5.zip |
Make path and source attributes mutually exclusive
Diffstat (limited to '')
-rw-r--r-- | askama/src/lib.rs | 4 | ||||
-rw-r--r-- | askama_shared/src/input.rs | 6 |
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"); |