/usr/share/doc/libghc-hakyll-doc/html/src/Hakyll-Web-Template.html is in libghc-hakyll-doc 4.9.2.0-1.
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/Hakyll/Web/Template.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-- | This module provides means for reading and applying 'Template's.</span>
<a name="line-2"></a><span class='hs-comment'>--</span>
<a name="line-3"></a><span class='hs-comment'>-- Templates are tools to convert items into a string. They are perfectly suited</span>
<a name="line-4"></a><span class='hs-comment'>-- for laying out your site.</span>
<a name="line-5"></a><span class='hs-comment'>--</span>
<a name="line-6"></a><span class='hs-comment'>-- Let's look at an example template:</span>
<a name="line-7"></a><span class='hs-comment'>--</span>
<a name="line-8"></a><span class='hs-comment'>-- > <html></span>
<a name="line-9"></a><span class='hs-comment'>-- > <head></span>
<a name="line-10"></a><span class='hs-comment'>-- > <title>My crazy homepage - $title$</title></span>
<a name="line-11"></a><span class='hs-comment'>-- > </head></span>
<a name="line-12"></a><span class='hs-comment'>-- > <body></span>
<a name="line-13"></a><span class='hs-comment'>-- > <div id="header"></span>
<a name="line-14"></a><span class='hs-comment'>-- > <h1>My crazy homepage - $title$</h1></span>
<a name="line-15"></a><span class='hs-comment'>-- > </div></span>
<a name="line-16"></a><span class='hs-comment'>-- > <div id="content"></span>
<a name="line-17"></a><span class='hs-comment'>-- > $body$</span>
<a name="line-18"></a><span class='hs-comment'>-- > </div></span>
<a name="line-19"></a><span class='hs-comment'>-- > <div id="footer"></span>
<a name="line-20"></a><span class='hs-comment'>-- > By reading this you agree that I now own your soul</span>
<a name="line-21"></a><span class='hs-comment'>-- > </div></span>
<a name="line-22"></a><span class='hs-comment'>-- > </body></span>
<a name="line-23"></a><span class='hs-comment'>-- > </html></span>
<a name="line-24"></a><span class='hs-comment'>--</span>
<a name="line-25"></a><span class='hs-comment'>-- As you can see, the format is very simple -- @$key$@ is used to render the</span>
<a name="line-26"></a><span class='hs-comment'>-- @$key$@ field from the page, everything else is literally copied. If you want</span>
<a name="line-27"></a><span class='hs-comment'>-- to literally insert @\"$key$\"@ into your page (for example, when you're</span>
<a name="line-28"></a><span class='hs-comment'>-- writing a Hakyll tutorial) you can use</span>
<a name="line-29"></a><span class='hs-comment'>--</span>
<a name="line-30"></a><span class='hs-comment'>-- > <p></span>
<a name="line-31"></a><span class='hs-comment'>-- > A literal $$key$$.</span>
<a name="line-32"></a><span class='hs-comment'>-- > </p></span>
<a name="line-33"></a><span class='hs-comment'>--</span>
<a name="line-34"></a><span class='hs-comment'>-- Because of it's simplicity, these templates can be used for more than HTML:</span>
<a name="line-35"></a><span class='hs-comment'>-- you could make, for example, CSS or JS templates as well.</span>
<a name="line-36"></a><span class='hs-comment'>--</span>
<a name="line-37"></a><span class='hs-comment'>-- Apart from interpolating @$key$@s from the 'Context' you can also</span>
<a name="line-38"></a><span class='hs-comment'>-- use the following macros:</span>
<a name="line-39"></a><span class='hs-comment'>--</span>
<a name="line-40"></a><span class='hs-comment'>-- * @$if(key)$@</span>
<a name="line-41"></a><span class='hs-comment'>--</span>
<a name="line-42"></a><span class='hs-comment'>-- > $if(key)$</span>
<a name="line-43"></a><span class='hs-comment'>-- > <b> Defined </b></span>
<a name="line-44"></a><span class='hs-comment'>-- > $else$</span>
<a name="line-45"></a><span class='hs-comment'>-- > <b> Non-defined </b></span>
<a name="line-46"></a><span class='hs-comment'>-- > $endif$</span>
<a name="line-47"></a><span class='hs-comment'>--</span>
<a name="line-48"></a><span class='hs-comment'>-- This example will print @Defined@ if @key@ is defined in the</span>
<a name="line-49"></a><span class='hs-comment'>-- context and @Non-defined@ otherwise. The @$else$@ clause is</span>
<a name="line-50"></a><span class='hs-comment'>-- optional.</span>
<a name="line-51"></a><span class='hs-comment'>--</span>
<a name="line-52"></a><span class='hs-comment'>-- * @$for(key)$@</span>
<a name="line-53"></a><span class='hs-comment'>--</span>
<a name="line-54"></a><span class='hs-comment'>-- The @for@ macro is used for enumerating 'Context' elements that are</span>
<a name="line-55"></a><span class='hs-comment'>-- lists, i.e. constructed using the 'listField' function. Assume that</span>
<a name="line-56"></a><span class='hs-comment'>-- in a context we have an element @listField \"key\" c itms@. Then</span>
<a name="line-57"></a><span class='hs-comment'>-- the snippet</span>
<a name="line-58"></a><span class='hs-comment'>--</span>
<a name="line-59"></a><span class='hs-comment'>-- > $for(key)$</span>
<a name="line-60"></a><span class='hs-comment'>-- > $x$</span>
<a name="line-61"></a><span class='hs-comment'>-- > $sep$,</span>
<a name="line-62"></a><span class='hs-comment'>-- > $endfor$</span>
<a name="line-63"></a><span class='hs-comment'>--</span>
<a name="line-64"></a><span class='hs-comment'>-- would, for each item @i@ in 'itms', lookup @$x$@ in the context @c@</span>
<a name="line-65"></a><span class='hs-comment'>-- with item @i@, interpolate it, and join the resulting list with</span>
<a name="line-66"></a><span class='hs-comment'>-- @,@.</span>
<a name="line-67"></a><span class='hs-comment'>--</span>
<a name="line-68"></a><span class='hs-comment'>-- Another concrete example one may consider is the following. Given the</span>
<a name="line-69"></a><span class='hs-comment'>-- context</span>
<a name="line-70"></a><span class='hs-comment'>--</span>
<a name="line-71"></a><span class='hs-comment'>-- > listField "things" (field "thing" (return . itemBody))</span>
<a name="line-72"></a><span class='hs-comment'>-- > (sequence [makeItem "fruits", makeItem "vegetables"])</span>
<a name="line-73"></a><span class='hs-comment'>--</span>
<a name="line-74"></a><span class='hs-comment'>-- and a template</span>
<a name="line-75"></a><span class='hs-comment'>--</span>
<a name="line-76"></a><span class='hs-comment'>-- > I like</span>
<a name="line-77"></a><span class='hs-comment'>-- > $for(things)$</span>
<a name="line-78"></a><span class='hs-comment'>-- > fresh $thing$$sep$, and</span>
<a name="line-79"></a><span class='hs-comment'>-- > $endfor$</span>
<a name="line-80"></a><span class='hs-comment'>--</span>
<a name="line-81"></a><span class='hs-comment'>-- the resulting page would look like</span>
<a name="line-82"></a><span class='hs-comment'>--</span>
<a name="line-83"></a><span class='hs-comment'>-- > <p></span>
<a name="line-84"></a><span class='hs-comment'>-- > I like</span>
<a name="line-85"></a><span class='hs-comment'>-- ></span>
<a name="line-86"></a><span class='hs-comment'>-- > fresh fruits, and</span>
<a name="line-87"></a><span class='hs-comment'>-- ></span>
<a name="line-88"></a><span class='hs-comment'>-- > fresh vegetables</span>
<a name="line-89"></a><span class='hs-comment'>-- > </p></span>
<a name="line-90"></a><span class='hs-comment'>--</span>
<a name="line-91"></a><span class='hs-comment'>-- The @$sep$@ part can be omitted. Usually, you can get by using the</span>
<a name="line-92"></a><span class='hs-comment'>-- 'applyListTemplate' and 'applyJoinListTemplate' functions.</span>
<a name="line-93"></a><span class='hs-comment'>--</span>
<a name="line-94"></a><span class='hs-comment'>-- * @$partial(path)$@</span>
<a name="line-95"></a><span class='hs-comment'>--</span>
<a name="line-96"></a><span class='hs-comment'>-- Loads a template located in a separate file and interpolates it</span>
<a name="line-97"></a><span class='hs-comment'>-- under the current context.</span>
<a name="line-98"></a><span class='hs-comment'>--</span>
<a name="line-99"></a><span class='hs-comment'>-- Assuming that the file @test.html@ contains</span>
<a name="line-100"></a><span class='hs-comment'>--</span>
<a name="line-101"></a><span class='hs-comment'>-- > <b>$key$</b></span>
<a name="line-102"></a><span class='hs-comment'>--</span>
<a name="line-103"></a><span class='hs-comment'>-- The result of rendering</span>
<a name="line-104"></a><span class='hs-comment'>--</span>
<a name="line-105"></a><span class='hs-comment'>-- > <p></span>
<a name="line-106"></a><span class='hs-comment'>-- > $partial("test.html")$</span>
<a name="line-107"></a><span class='hs-comment'>-- > </p></span>
<a name="line-108"></a><span class='hs-comment'>--</span>
<a name="line-109"></a><span class='hs-comment'>-- is the same as the result of rendering</span>
<a name="line-110"></a><span class='hs-comment'>--</span>
<a name="line-111"></a><span class='hs-comment'>-- > <p></span>
<a name="line-112"></a><span class='hs-comment'>-- > <b>$key$</b></span>
<a name="line-113"></a><span class='hs-comment'>-- > </p></span>
<a name="line-114"></a><span class='hs-comment'>--</span>
<a name="line-115"></a><span class='hs-comment'>-- That is, calling @$partial$@ is equivalent to just copying and pasting</span>
<a name="line-116"></a><span class='hs-comment'>-- template code.</span>
<a name="line-117"></a><span class='hs-comment'>--</span>
<a name="line-118"></a><span class='hs-comment'>-- In the examples above you can see that the outputs contain a lot of leftover</span>
<a name="line-119"></a><span class='hs-comment'>-- whitespace that you may wish to remove. Using @'$-'@ or @'-$'@ instead of</span>
<a name="line-120"></a><span class='hs-comment'>-- @'$'@ in a macro strips all whitespace to the left or right of that clause</span>
<a name="line-121"></a><span class='hs-comment'>-- respectively. Given the context</span>
<a name="line-122"></a><span class='hs-comment'>--</span>
<a name="line-123"></a><span class='hs-comment'>-- > listField "counts" (field "count" (return . itemBody))</span>
<a name="line-124"></a><span class='hs-comment'>-- > (sequence [makeItem "3", makeItem "2", makeItem "1"])</span>
<a name="line-125"></a><span class='hs-comment'>--</span>
<a name="line-126"></a><span class='hs-comment'>-- and a template</span>
<a name="line-127"></a><span class='hs-comment'>--</span>
<a name="line-128"></a><span class='hs-comment'>-- > <p></span>
<a name="line-129"></a><span class='hs-comment'>-- > $for(counts)-$</span>
<a name="line-130"></a><span class='hs-comment'>-- > $count$</span>
<a name="line-131"></a><span class='hs-comment'>-- > $-sep$...</span>
<a name="line-132"></a><span class='hs-comment'>-- > $-endfor$</span>
<a name="line-133"></a><span class='hs-comment'>-- > </p></span>
<a name="line-134"></a><span class='hs-comment'>--</span>
<a name="line-135"></a><span class='hs-comment'>-- the resulting page would look like</span>
<a name="line-136"></a><span class='hs-comment'>--</span>
<a name="line-137"></a><span class='hs-comment'>-- > <p></span>
<a name="line-138"></a><span class='hs-comment'>-- > 3...2...1</span>
<a name="line-139"></a><span class='hs-comment'>-- > </p></span>
<a name="line-140"></a><span class='hs-comment'>--</span>
<a name="line-141"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Hakyll</span><span class='hs-varop'>.</span><span class='hs-conid'>Web</span><span class='hs-varop'>.</span><span class='hs-conid'>Template</span>
<a name="line-142"></a> <span class='hs-layout'>(</span> <span class='hs-conid'>Template</span>
<a name="line-143"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>templateBodyCompiler</span>
<a name="line-144"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>templateCompiler</span>
<a name="line-145"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>applyTemplate</span>
<a name="line-146"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>loadAndApplyTemplate</span>
<a name="line-147"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>applyAsTemplate</span>
<a name="line-148"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>readTemplate</span>
<a name="line-149"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>unsafeReadTemplateFile</span>
<a name="line-150"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-151"></a>
<a name="line-152"></a>
<a name="line-153"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-154"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Hakyll</span><span class='hs-varop'>.</span><span class='hs-conid'>Web</span><span class='hs-varop'>.</span><span class='hs-conid'>Template</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
</pre></body>
</html>
|