aboutsummaryrefslogtreecommitdiff
path: root/mustache/src/Text/Mustache/Render.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-05-27 20:21:15 +0200
committerMirek Kratochvil <exa.exa@gmail.com>2023-05-27 20:21:15 +0200
commit08742b6b310468ac5e6e09adb5a31d300c998411 (patch)
treef6caa335f6220769dee3737805e38021a18f3e8c /mustache/src/Text/Mustache/Render.hs
parent73498534cfdccab95e580f8d6b121655d00e7578 (diff)
downloadreploy-08742b6b310468ac5e6e09adb5a31d300c998411.tar.gz
reploy-08742b6b310468ac5e6e09adb5a31d300c998411.tar.bz2
implement simple harmless "true check" to mustache
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) =