summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorsamgd <sam@samgd.com>2016-07-23 12:41:41 +0200
committersamgd <sam@samgd.com>2016-07-23 12:41:41 +0200
commit6e14d33a101e4ea9559d13d7a562da7ebc72acf2 (patch)
treee8cfc4c4f853ab1c6295e06430a5e64e53bc623d /src/Hakyll
parent6c0be2e2d3b8992263573540b3498ea51b10b2e6 (diff)
downloadhakyll-6e14d33a101e4ea9559d13d7a562da7ebc72acf2.tar.gz
For trimming
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Web/Template/Internal.hs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs
index 89bda52..983bd16 100644
--- a/src/Hakyll/Web/Template/Internal.hs
+++ b/src/Hakyll/Web/Template/Internal.hs
@@ -141,7 +141,7 @@ template :: P.Parser Template
template = mconcat <$> P.many (P.choice [ lift chunk
, lift escaped
, conditional
- , lift for
+ , for
, lift partial
, lift expr
])
@@ -222,15 +222,27 @@ conditional = P.try $ do
--------------------------------------------------------------------------------
-for :: P.Parser TemplateElement
+for :: P.Parser Template
for = P.try $ do
- void $ P.string "$for("
+ trimLFor <- trimOpen
+ void $ P.string "for("
e <- expr'
- void $ P.string ")$"
+ void $ P.char ')'
+ trimRFor <- trimClose
+
body <- template
sep <- P.optionMaybe $ P.try (P.string "$sep$") >> template
- void $ P.string "$endfor$"
- return $ For e body sep
+
+ trimLEnd <- trimOpen
+ void $ P.string "endfor"
+ trimREnd <- trimClose
+
+ pure $ Template $ mconcat [ [TrimL | trimLFor]
+ , [TrimR | trimRFor]
+ , [For e body sep]
+ , [TrimL | trimLEnd]
+ , [TrimR | trimREnd]
+ ]
--------------------------------------------------------------------------------