aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askama/src/lib.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index b922906..aa21eed 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -20,12 +20,12 @@ pub use path::rerun_if_templates_changed;
struct TemplateMeta {
path: String,
- print: bool,
+ print: String,
}
fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
let mut path = None;
- let mut print = false;
+ let mut print = "none".to_string();
let attr = ast.attrs.iter().find(|a| a.name() == "template").unwrap();
if let syn::MetaItem::List(_, ref inner) = attr.value {
for nm_item in inner {
@@ -38,7 +38,7 @@ fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
panic!("template path must be string literal");
},
"print" => if let syn::Lit::Str(ref s, _) = *val {
- print = s == "true";
+ print = s.clone();
} else {
panic!("print value must be string literal");
},
@@ -58,8 +58,11 @@ pub fn build_template(ast: &syn::DeriveInput) -> String {
let meta = get_template_meta(ast);
let src = path::get_template_source(&meta.path);
let nodes = parser::parse(&src);
+ if meta.print == "ast" || meta.print == "all" {
+ println!("{:?}", nodes);
+ }
let code = generator::generate(ast, &meta.path, nodes);
- if meta.print {
+ if meta.print == "code" || meta.print == "all" {
println!("{}", code);
}
code