summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-09-08 12:04:47 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-09-08 12:04:47 -0700
commitc78557f3ca333d9ae925fdcb8a7c03199f5e47fd (patch)
treef37cd1e4f9a562cd0a736f976c583cf668c0c455 /src
parentf8ecda0152990f4e1c7a6b5f45cecdefe5ac54f5 (diff)
Templates: more consistent behavior of `$for$`.
When `foo` is not a list, `$for(foo)$...$endfor$` should behave like $if(foo)$...$endif$. So if `foo` resolves to "", no output should be produced. See pandoc-templates#39.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Templates.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index 22a44e735..7f744c7e1 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -212,7 +212,7 @@ iter var' template sep = Template $ \val -> unTemplate
Just (Array vec) -> mconcat $ intersperse sep
$ map (setVar template var')
$ toList vec
- Just x -> setVar template var' x
+ Just x -> cond var' (setVar template var' x) mempty
Nothing -> mempty) val
setVar :: Template -> Variable -> Value -> Template