From 2257afd356e6985244e702554aeda74af63b7ff1 Mon Sep 17 00:00:00 2001 From: Anthony Nowell Date: Wed, 1 Nov 2017 21:19:34 -0700 Subject: Support matching custom enums --- askama_shared/src/generator.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'askama_shared/src/generator.rs') 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 + } } } -- cgit