aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Anthony Nowell <anowell@gmail.com>2017-11-01 21:19:34 -0700
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-11-02 15:11:20 +0100
commit2257afd356e6985244e702554aeda74af63b7ff1 (patch)
treee4850337eb72afb32cbd259f3b79f114cef05a9b /askama_shared/src/generator.rs
parent89a90eb46c822957af5b6aef8615a7d7398e7de4 (diff)
downloadaskama-2257afd356e6985244e702554aeda74af63b7ff1.tar.gz
askama-2257afd356e6985244e702554aeda74af63b7ff1.tar.bz2
askama-2257afd356e6985244e702554aeda74af63b7ff1.zip
Support matching custom enums
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index 701de02..356c927 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -1,6 +1,6 @@
use filters;
use input::TemplateInput;
-use parser::{self, Cond, Expr, Macro, MatchParameter, Node, Target, When, WS};
+use parser::{self, Cond, Expr, Macro, MatchParameter, MatchVariant, Node, Target, When, WS};
use path;
use quote::{Tokens, ToTokens};
@@ -635,19 +635,24 @@ impl<'a> Generator<'a> {
}
}
- fn visit_match_variant(&mut self, param: &MatchParameter) -> DisplayWrap {
+ fn visit_match_variant(&mut self, param: &MatchVariant) -> DisplayWrap {
match *param {
- MatchParameter::StrLit(s) => self.visit_str_lit(s),
- MatchParameter::NumLit(s) => {
+ MatchVariant::StrLit(s) => self.visit_str_lit(s),
+ MatchVariant::NumLit(s) => {
// Variants need to be references until match-modes land
self.write("&");
self.visit_num_lit(s)
},
- MatchParameter::Name(s) => {
+ MatchVariant::Name(s) => {
self.write("&");
self.write(s);
DisplayWrap::Unwrapped
}
+ MatchVariant::Path(ref s) => {
+ self.write("&");
+ self.write(&s.join("::"));
+ DisplayWrap::Unwrapped
+ }
}
}