aboutsummaryrefslogtreecommitdiff
path: root/mustache/src/Text/Mustache/Render.hs
diff options
context:
space:
mode:
Diffstat (limited to 'mustache/src/Text/Mustache/Render.hs')
-rw-r--r--mustache/src/Text/Mustache/Render.hs12
1 files changed, 12 insertions, 0 deletions
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) =