aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/input.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-21 12:17:45 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-21 12:17:45 +0200
commitf05a924c49afb537b624cfe3cbef3a95b13759a2 (patch)
tree7c4b5d978c6e13a1a48d15caacc4291f89d8addd /askama_derive/src/input.rs
parente09cdfaf1f9cca45ed320c3ad97f3502c48ff73d (diff)
downloadaskama-f05a924c49afb537b624cfe3cbef3a95b13759a2.tar.gz
askama-f05a924c49afb537b624cfe3cbef3a95b13759a2.tar.bz2
askama-f05a924c49afb537b624cfe3cbef3a95b13759a2.zip
Inline TemplateMeta into TemplateInput
Diffstat (limited to 'askama_derive/src/input.rs')
-rw-r--r--askama_derive/src/input.rs43
1 files changed, 20 insertions, 23 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 62c1072..6c631be 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -7,34 +7,15 @@ use syn;
pub struct TemplateInput<'a> {
pub ast: &'a syn::DeriveInput,
- pub meta: TemplateMeta,
- pub path: PathBuf,
-}
-
-impl<'a> TemplateInput<'a> {
- pub fn new(ast: &'a syn::DeriveInput) -> TemplateInput<'a> {
- let meta = TemplateMeta::new(ast);
- let path = match meta.source {
- Source::Source(_) => match meta.ext {
- Some(ref v) => PathBuf::from(format!("{}.{}", ast.ident, v)),
- None => PathBuf::new(),
- },
- Source::Path(ref s) => path::find_template_from_path(s, None),
- };
- TemplateInput { ast, meta, path }
- }
-}
-
-// Holds metadata for the template, based on the `template()` attribute.
-pub struct TemplateMeta {
pub source: Source,
pub print: Print,
pub escaping: EscapeMode,
pub ext: Option<String>,
+ pub path: PathBuf,
}
-impl TemplateMeta {
- fn new(ast: &syn::DeriveInput) -> TemplateMeta {
+impl<'a> TemplateInput<'a> {
+ pub fn new(ast: &'a syn::DeriveInput) -> TemplateInput<'a> {
let attr = ast.attrs
.iter()
.find(|a| a.interpret_meta().unwrap().name() == "template");
@@ -115,7 +96,23 @@ impl TemplateMeta {
}
},
};
- TemplateMeta { source, print, escaping, ext }
+
+ let path = match source {
+ Source::Source(_) => match ext {
+ Some(ref v) => PathBuf::from(format!("{}.{}", ast.ident, v)),
+ None => PathBuf::new(),
+ },
+ Source::Path(ref s) => path::find_template_from_path(s, None),
+ };
+
+ TemplateInput {
+ ast,
+ source,
+ print,
+ escaping,
+ ext,
+ path,
+ }
}
}