<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Text.Pandoc.Templates</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Text-Pandoc-Templates.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Text-Pandoc-Templates.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">pandoc-1.8.2.1: Conversion between markup formats</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>alpha</td></tr><tr><th>Maintainer</th><td>John MacFarlane <jgm@berkeley.edu></td></tr></table><p class="caption">Text.Pandoc.Templates</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A simple templating system with variable substitution and conditionals. Example: </p><pre> renderTemplate [("name","Sam"),("salary","50,000")] $ "Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$" "Hi, John. You make $50,000." </pre><p>A slot for an interpolated variable is a variable name surrounded by dollar signs. To include a literal <code>$</code> in your template, use <code>$$</code>. Variable names must begin with a letter and can contain letters, numbers, <code>_</code>, and <code>-</code>. </p><p>The value of a variable will be indented to the same level as the variable. </p><p>A conditional begins with <code>$if(variable_name)$</code> and ends with <code>$endif$</code>. It may optionally contain an <code>$else$</code> section. The if section is used if <code>variable_name</code> has a non-null value, otherwise the else section is used. </p><p>Conditional keywords should not be indented, or unexpected spacing problems may occur. </p><p>If a variable name is associated with multiple values in the association list passed to <code><a href="Text-Pandoc-Templates.html#v:renderTemplate">renderTemplate</a></code>, you may use the <code>$for$</code> keyword to iterate over them: </p><pre> renderTemplate [("name","Sam"),("name","Joe")] $ "$for(name)$\nHi, $name$.\n$endfor$" "Hi, Sam.\nHi, Joe." </pre><p>You may optionally specify separators using <code>$sep$</code>: </p><pre> renderTemplate [("name","Sam"),("name","Joe"),("name","Lynn")] $ "Hi, $for(name)$$name$$sep$, $endfor$" "Hi, Sam, Joe, Lynn." </pre></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:renderTemplate">renderTemplate</a> :: <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> a => [(<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>)] -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> a</li><li class="src short"><span class="keyword">class</span> <a href="#t:TemplateTarget">TemplateTarget</a> a </li><li class="src short"><a href="#v:getDefaultTemplate">getDefaultTemplate</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Control-Exception-Base.html#t:IOException">IOException</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>)</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a name="v:renderTemplate" class="def">renderTemplate</a><a href="src/Text-Pandoc-Templates.html#renderTemplate" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> a</td><td class="doc empty"> </td></tr><tr><td class="src">=> [(<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>)]</td><td class="doc"><p>Assoc. list of values for variables </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>Template </p></td></tr><tr><td class="src">-> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Renders a template </p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:TemplateTarget" class="def">TemplateTarget</a> a <a href="src/Text-Pandoc-Templates.html#TemplateTarget" class="link">Source</a></p><div class="subs instances"><p id="control.i:TemplateTarget" class="caption collapser" onclick="toggleSection('i:TemplateTarget')">Instances</p><div id="section.i:TemplateTarget" class="show"><table><tr><td class="src"><a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> <a href="/usr/share/doc/ghc/html/libraries/bytestring-0.9.1.10/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> <a href="/usr/share/doc/ghc/html/libraries/xhtml-3000.2.0.1/Text-XHtml-Strict.html#t:Html">Html</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:getDefaultTemplate" class="def">getDefaultTemplate</a><a href="src/Text-Pandoc-Templates.html#getDefaultTemplate" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>User data directory to search first </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>Name of writer </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Control-Exception-Base.html#t:IOException">IOException</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>)</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Get default template for the specified writer. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>