From 08742b6b310468ac5e6e09adb5a31d300c998411 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 27 May 2023 20:21:15 +0200 Subject: implement simple harmless "true check" to mustache --- mustache/src/Text/Mustache/Render.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mustache/src/Text/Mustache/Render.hs') diff --git a/mustache/src/Text/Mustache/Render.hs b/mustache/src/Text/Mustache/Render.hs index 7a0ad89..b0ae5b6 100644 --- a/mustache/src/Text/Mustache/Render.hs +++ b/mustache/src/Text/Mustache/Render.hs @@ -148,6 +148,18 @@ substituteNode (Section (NamedData secName) secSTree) = shiftContext newContext $ substituteAST secSTree Nothing -> tellError $ SectionTargetNotFound secName +-- substituting an existing section (exact invert of the inverted section) +substituteNode (ExistingSection Implicit _) = tellError InvertedImplicitSection +substituteNode (ExistingSection (NamedData secName) invSecSTree) = + search secName >>= \case + Just (Bool False) -> return () + Just (Array a) | V.null a -> return () + Just Null -> return () + Nothing -> return () + _ -> contents + where + contents = mapM_ substituteNode invSecSTree + -- substituting an inverted section substituteNode (InvertedSection Implicit _) = tellError InvertedImplicitSection substituteNode (InvertedSection (NamedData secName) invSecSTree) = -- cgit v1.2.3