diff options
author | Anthony Nowell <anowell@gmail.com> | 2017-11-01 21:19:34 -0700 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-11-02 15:11:20 +0100 |
commit | 2257afd356e6985244e702554aeda74af63b7ff1 (patch) | |
tree | e4850337eb72afb32cbd259f3b79f114cef05a9b /askama_shared/src/generator.rs | |
parent | 89a90eb46c822957af5b6aef8615a7d7398e7de4 (diff) | |
download | askama-2257afd356e6985244e702554aeda74af63b7ff1.tar.gz askama-2257afd356e6985244e702554aeda74af63b7ff1.tar.bz2 askama-2257afd356e6985244e702554aeda74af63b7ff1.zip |
Support matching custom enums
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/generator.rs | 15 |
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 + } } } |