/usr/share/doc/libghc-pandoc-doc/html/Text-Pandoc-Templates.html is in libghc-pandoc-doc 1.12.2.1-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <!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.12.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><tr><th>Safe Haskell</th><td>None</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.
The following program illustrates its use:
</p><pre>
import Data.Text
import Data.Aeson
import Text.Pandoc.Templates
data Employee = Employee { firstName :: String
, lastName :: String
, salary :: Maybe Int }
instance ToJSON Employee where
toJSON e = object [ "name" .= object [ "first" .= firstName e
, "last" .= lastName e ]
, "salary" .= salary e ]
employees :: [Employee]
employees = [ Employee "John" "Doe" Nothing
, Employee "Omar" "Smith" (Just 30000)
, Employee "Sara" "Chen" (Just 60000) ]
template :: Template
template = either error id $ compileTemplate
"$for(employee)$Hi, $employee.name.first$. $if(employee.salary)$You make $employee.salary$.$else$No salary data.$endif$$sep$\n$endfor$"
main = putStrLn $ renderTemplate template $ object ["employee" .= employees ]
</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>, <code>-</code>, and <code>.</code>.
</p><p>The values of variables are determined by a JSON object that is
passed as a parameter to <code>renderTemplate</code>. So, for example,
<code>title</code> will return the value of the <code>title</code> field, and
<code>employee.salary</code> will return the value of the <code>salary</code> field
of the object that is the value of the <code>employee</code> field.
</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>The <code>$for$</code> keyword can be used to iterate over an array. If
the value of the associated variable is not an array, a single
iteration will be performed on its value.
</p><p>You may optionally specify separators using <code>$sep$</code>, as in the
example above.
</p></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="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="Text-Pandoc-Templates.html#t:Template">Template</a> -> a -> b</li><li class="src short"><a href="#v:renderTemplate-39-">renderTemplate'</a> :: (<a href="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> a -> b</li><li class="src short"><span class="keyword">class</span> <a href="#t:TemplateTarget">TemplateTarget</a> a <span class="keyword">where</span><ul class="subs"><li><a href="#v:toTarget">toTarget</a> :: <a href="/usr/share/doc/libghc-text-doc/html/Data-Text-Internal.html#t:Text">Text</a> -> a</li></ul></li><li class="src short"><a href="#v:varListToJSON">varListToJSON</a> :: [(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a>, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a>)] -> <a href="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Value">Value</a></li><li class="src short"><a href="#v:compileTemplate">compileTemplate</a> :: <a href="/usr/share/doc/libghc-text-doc/html/Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> <a href="Text-Pandoc-Templates.html#t:Template">Template</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Template">Template</a> </li><li class="src short"><a href="#v:getDefaultTemplate">getDefaultTemplate</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:FilePath">FilePath</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Exception-Base.html#t:IOException">IOException</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.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="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="Text-Pandoc-Templates.html#t:Template">Template</a> -> a -> b<a href="src/Text-Pandoc-Templates.html#renderTemplate" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:renderTemplate-39-" class="def">renderTemplate'</a> :: (<a href="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-Pandoc-Templates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> a -> b<a href="src/Text-Pandoc-Templates.html#renderTemplate%27" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Text-Pandoc-Templates.html#v:renderTemplate">renderTemplate</a></code>, but compiles the template first,
raising an error if compilation fails.
</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:TemplateTarget" class="def">TemplateTarget</a> a <span class="keyword">where</span><a href="src/Text-Pandoc-Templates.html#TemplateTarget" class="link">Source</a></p><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:toTarget" class="def">toTarget</a> :: <a href="/usr/share/doc/libghc-text-doc/html/Data-Text-Internal.html#t:Text">Text</a> -> a<a href="src/Text-Pandoc-Templates.html#toTarget" class="link">Source</a></p></div><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-doc/html/libraries/base-4.6.0.1/Data-String.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-doc/html/libraries/bytestring-0.10.0.2/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/libghc-text-doc/html/Data-Text-Internal.html#t:Text">Text</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/libghc-blaze-html-doc/html/Text-Blaze-Html.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:varListToJSON" class="def">varListToJSON</a> :: [(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a>, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a>)] -> <a href="/usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Value">Value</a><a href="src/Text-Pandoc-Templates.html#varListToJSON" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:compileTemplate" class="def">compileTemplate</a> :: <a href="/usr/share/doc/libghc-text-doc/html/Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> <a href="Text-Pandoc-Templates.html#t:Template">Template</a><a href="src/Text-Pandoc-Templates.html#compileTemplate" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Template" class="def">Template</a> <a href="src/Text-Pandoc-Templates.html#Template" class="link">Source</a></p><div class="subs instances"><p id="control.i:Template" class="caption collapser" onclick="toggleSection('i:Template')">Instances</p><div id="section.i:Template" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Monoid.html#t:Monoid">Monoid</a> <a href="Text-Pandoc-Templates.html#t:Template">Template</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-doc/html/libraries/base-4.6.0.1/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/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-doc/html/libraries/base-4.6.0.1/Data-String.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-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Exception-Base.html#t:IOException">IOException</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.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.13.2</p></div></body></html>
|