/usr/share/doc/libghc-doctemplates-doc/html/Text-DocTemplates.html is in libghc-doctemplates-doc 0.1.0.2-2build1.
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 | <!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.DocTemplates</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Text-DocTemplates.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Text-DocTemplates.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">doctemplates-0.1.0.2: Pandoc-style document templates</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>Copyright (C) 2009-2016 John MacFarlane</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>John MacFarlane <jgm@berkeley.edu></td></tr><tr><th>Stability</th><td>alpha</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Text.DocTemplates</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A simple templating system with variable substitution and conditionals.
This module was formerly part of pandoc and is used for pandoc's
templates. The following program illustrates its use:</p><pre>
import Data.Text
import Data.Aeson
import Text.DocTemplates
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 ]
template :: Text
template = "$for(employee)$Hi, $employee.name.first$. $if(employee.salary)$You make $employee.salary$.$else$No salary data.$endif$$sep$\n$endfor$"
main = case compileTemplate template of
Left e -> error e
Right t -> putStrLn $ renderTemplate t $ object
["employee" .=
[ Employee "John" "Doe" Nothing
, Employee "Omar" "Smith" (Just 30000)
, Employee "Sara" "Chen" (Just 60000) ]
]</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="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="Text-DocTemplates.html#t:Template">Template</a> -> a -> b</li><li class="src short"><a href="#v:applyTemplate">applyTemplate</a> :: (<a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</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"></ul></li><li class="src short"><a href="#v:varListToJSON">varListToJSON</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///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="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> <a href="Text-DocTemplates.html#t:Template">Template</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Template">Template</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:renderTemplate" class="def">renderTemplate</a> :: (<a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="Text-DocTemplates.html#t:Template">Template</a> -> a -> b <a href="src/Text-DocTemplates.html#renderTemplate" class="link">Source</a> <a href="#v:renderTemplate" class="selflink">#</a></p><div class="doc"><p>Render a compiled template using <code>context</code> to resolve variables.</p></div></div><div class="top"><p class="src"><a id="v:applyTemplate" class="def">applyTemplate</a> :: (<a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a> a, <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> b) => <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> b <a href="src/Text-DocTemplates.html#applyTemplate" class="link">Source</a> <a href="#v:applyTemplate" class="selflink">#</a></p><div class="doc"><p>Combines <code><a href="Text-DocTemplates.html#v:renderTemplate">renderTemplate</a></code> and <code><a href="Text-DocTemplates.html#v:compileTemplate">compileTemplate</a></code>.</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:TemplateTarget" class="def">TemplateTarget</a> a <span class="keyword">where</span> <a href="src/Text-DocTemplates.html#TemplateTarget" class="link">Source</a> <a href="#t:TemplateTarget" class="selflink">#</a></p><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Text-DocTemplates.html#v:toTarget">toTarget</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:toTarget" class="def">toTarget</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> a <a href="src/Text-DocTemplates.html#toTarget" class="link">Source</a> <a href="#v:toTarget" class="selflink">#</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 clearfix"><span class="inst-left"><span id="control.i:ic:TemplateTarget:TemplateTarget:1" class="instance expander" onclick="toggleSection('i:ic:TemplateTarget:TemplateTarget:1')"></span> <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></span> <a href="src/Text-DocTemplates.html#line-117" class="link">Source</a> <a href="#t:TemplateTarget" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:TemplateTarget:TemplateTarget:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toTarget">toTarget</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> <a href="src/Text-DocTemplates.html#toTarget" class="link">Source</a> <a href="#v:toTarget" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:TemplateTarget:TemplateTarget:2" class="instance expander" onclick="toggleSection('i:ic:TemplateTarget:TemplateTarget:2')"></span> <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a></span> <a href="src/Text-DocTemplates.html#line-114" class="link">Source</a> <a href="#t:TemplateTarget" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:TemplateTarget:TemplateTarget:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toTarget">toTarget</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> <a href="src/Text-DocTemplates.html#toTarget" class="link">Source</a> <a href="#v:toTarget" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:TemplateTarget:TemplateTarget:3" class="instance expander" onclick="toggleSection('i:ic:TemplateTarget:TemplateTarget:3')"></span> <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></span> <a href="src/Text-DocTemplates.html#line-111" class="link">Source</a> <a href="#t:TemplateTarget" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:TemplateTarget:TemplateTarget:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toTarget">toTarget</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="src/Text-DocTemplates.html#toTarget" class="link">Source</a> <a href="#v:toTarget" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:TemplateTarget:TemplateTarget:4" class="instance expander" onclick="toggleSection('i:ic:TemplateTarget:TemplateTarget:4')"></span> <a href="Text-DocTemplates.html#t:TemplateTarget">TemplateTarget</a> <a href="file:///usr/share/doc/libghc-blaze-html-doc/html/Text-Blaze-Html.html#t:Html">Html</a></span> <a href="src/Text-DocTemplates.html#line-120" class="link">Source</a> <a href="#t:TemplateTarget" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:TemplateTarget:TemplateTarget:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toTarget">toTarget</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/libghc-blaze-html-doc/html/Text-Blaze-Html.html#t:Html">Html</a> <a href="src/Text-DocTemplates.html#toTarget" class="link">Source</a> <a href="#v:toTarget" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:varListToJSON" class="def">varListToJSON</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Value">Value</a> <a href="src/Text-DocTemplates.html#varListToJSON" class="link">Source</a> <a href="#v:varListToJSON" class="selflink">#</a></p><div class="doc"><p>A convenience function for passing in an association
list of string values instead of a JSON <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Value">Value</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:compileTemplate" class="def">compileTemplate</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Either.html#t:Either">Either</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> <a href="Text-DocTemplates.html#t:Template">Template</a> <a href="src/Text-DocTemplates.html#compileTemplate" class="link">Source</a> <a href="#v:compileTemplate" class="selflink">#</a></p><div class="doc"><p>Compile a template.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Template" class="def">Template</a> <a href="src/Text-DocTemplates.html#Template" class="link">Source</a> <a href="#t:Template" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Text-DocTemplates.html#t:Template">Template</a></code> is essentially a function that takes
a JSON <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:Value">Value</a></code> and produces <code><a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></code>.</p></div><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 clearfix"><span class="inst-left"><span id="control.i:id:Template:Monoid:1" class="instance expander" onclick="toggleSection('i:id:Template:Monoid:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Monoid.html#t:Monoid">Monoid</a> <a href="Text-DocTemplates.html#t:Template">Template</a></span> <a href="src/Text-DocTemplates.html#line-104" class="link">Source</a> <a href="#t:Template" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:Template:Monoid:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="Text-DocTemplates.html#t:Template">Template</a> <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="Text-DocTemplates.html#t:Template">Template</a> -> <a href="Text-DocTemplates.html#t:Template">Template</a> -> <a href="Text-DocTemplates.html#t:Template">Template</a> <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="Text-DocTemplates.html#t:Template">Template</a>] -> <a href="Text-DocTemplates.html#t:Template">Template</a> <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr></table></div></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|