From 5867b450e3f8027e4d7b8cc324c44f90e1d84e31 Mon Sep 17 00:00:00 2001 From: Regis Philibert Date: Tue, 25 Jan 2022 11:38:16 -0500 Subject: [PATCH] Allow slice of strings as env/When context Fixes #52 --- core/env/When.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/env/When.html b/core/env/When.html index 6687b49..e7bb049 100644 --- a/core/env/When.html +++ b/core/env/When.html @@ -7,7 +7,7 @@ @author @regisphilibert - @context Map (.) + @context String | Slice of Strings (.) @access private @@ -19,12 +19,21 @@ {{ end }} */}} {{ $return := false }} + +{{ $env := partialCached "huge/env/Get" "Get" }} + {{ if eq $ "never" }} {{ $return = false }} {{ else if eq $ "always" }} {{ $return = true }} {{ else }} - {{ $return = partialCached "huge/env/Is" $ $ }} + {{/* If the context is a Slice, we'll test all the slice's strings against the current environment */}} + {{ if reflect.IsSlice $ }} + {{ $return = in $ $env }} + {{/* Else, we just test the lone string */}} + {{ else }} + {{ $return = eq $ $env }} + {{ end }} {{ end }} {{ return $return }} \ No newline at end of file