<?xml version="1.0" encoding="utf-8" ?>
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
<title>Templates</title>
<style type="text/css">

/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2005-12-18 01:56:14 +0100 (Sun, 18 Dec 2005) $
:Revision: $Revision: 4224 $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin-left: 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left {
  clear: left }

img.align-right {
  clear: right }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font-family: serif ;
  font-size: 100% }

pre.literal-block, pre.doctest-block {
  margin-left: 2em ;
  margin-right: 2em ;
  background-color: #eeeeee }

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

tt.docutils {
  background-color: #eeeeee }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="templates">
<span id="topics-templates"></span><h1 class="title">Templates</h1>
<div class="admonition-about-this-document admonition">
<p class="first admonition-title">About this document</p>
<p class="last">This document describes the templates, template tags and filters provided by
the library.</p>
</div>
<div class="contents topic">
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
<ul class="simple">
<li><a class="reference" href="#template-files" id="id1" name="id1">Template files</a></li>
<li><a class="reference" href="#template-tags-and-filters" id="id2" name="id2">Template tags and filters</a><ul>
<li><a class="reference" href="#tag-reference" id="id3" name="id3">Tag reference</a><ul>
<li><a class="reference" href="#last-modified-pages" id="id4" name="id4"><tt class="docutils literal"><span class="pre">last_modified_pages</span></tt></a></li>
<li><a class="reference" href="#pagelink" id="id5" name="id5"><tt class="docutils literal"><span class="pre">pagelink</span></tt></a></li>
<li><a class="reference" href="#wikilink" id="id6" name="id6"><tt class="docutils literal"><span class="pre">wikilink</span></tt></a></li>
<li><a class="reference" href="#wikimenu" id="id7" name="id7"><tt class="docutils literal"><span class="pre">wikimenu</span></tt></a></li>
<li><a class="reference" href="#wikis" id="id8" name="id8"><tt class="docutils literal"><span class="pre">wikis</span></tt></a></li>
</ul>
</li>
<li><a class="reference" href="#filter-reference" id="id9" name="id9">Filter reference</a><ul>
<li><a class="reference" href="#in-list" id="id10" name="id10"><tt class="docutils literal"><span class="pre">in_list</span></tt></a></li>
<li><a class="reference" href="#sanitize" id="id11" name="id11"><tt class="docutils literal"><span class="pre">sanitize</span></tt></a></li>
<li><a class="reference" href="#wiki" id="id12" name="id12"><tt class="docutils literal"><span class="pre">wiki</span></tt></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<p>See also the <a class="reference" href="models.html">models documentation</a>, <a class="reference" href="views.html">views documentation</a>, and <a class="reference" href="forms.html">forms documentation</a>.</p>
<div class="section">
<h1><a class="toc-backref" href="#id1" id="template-files" name="template-files">Template files</a></h1>
<p>The softwarefabrica wiki application includes all the necessary templates. These
are provided in the <tt class="docutils literal"><span class="pre">template</span></tt> directory, and in particular in its <tt class="docutils literal"><span class="pre">wiki</span></tt>
subdirectory.</p>
<p>Templates are notoriously hard to make general enough for all the possible
uses. We've tried to provide a design simple enough to be easily understood, but
complete and functional for a real wiki project.</p>
<p>Almost all the templates inherit from <tt class="docutils literal"><span class="pre">wiki/base.html</span></tt>, which provides a
simple two column layout, with a right sidebar containing the wiki menu. In many
cases it should be possible to customize the layout and appearance by simply
providing a custom <tt class="docutils literal"><span class="pre">wiki/base.html</span></tt> in your application, somewhere in
<tt class="docutils literal"><span class="pre">TEMPLATE_DIRS</span></tt> where Django can find it.</p>
</div>
<div class="section">
<h1><a class="toc-backref" href="#id2" id="template-tags-and-filters" name="template-tags-and-filters">Template tags and filters</a></h1>
<p>Template tags and filters are defined in modules contained inside the
<tt class="docutils literal"><span class="pre">templatetags</span></tt> directory.</p>
<p>These can be loaded using <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">TAGMODULE</span> <span class="pre">%}</span></tt> in your templates.</p>
<div class="section">
<h2><a class="toc-backref" href="#id3" id="tag-reference" name="tag-reference">Tag reference</a></h2>
<div class="section">
<h3><a class="toc-backref" href="#id4" id="last-modified-pages" name="last-modified-pages"><tt class="docutils literal"><span class="pre">last_modified_pages</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">recentpages</span> <span class="pre">%}</span></tt></p>
<p>An inclusion tag, using the template <tt class="docutils literal"><span class="pre">wiki/tags/last_modified_pages.html</span></tt>.
Renders the template, populating its context with <tt class="docutils literal"><span class="pre">wiki</span></tt> and <tt class="docutils literal"><span class="pre">pages</span></tt>
variables.
<tt class="docutils literal"><span class="pre">wiki</span></tt> is the passed <tt class="docutils literal"><span class="pre">Wiki</span></tt> instance, if passed or <tt class="docutils literal"><span class="pre">None</span></tt>.
<tt class="docutils literal"><span class="pre">pages</span></tt> contains the most recently modified pages, from the most to the least
recent. By default up to ten pages are reported, but the number can be passed as
a second parameter.</p>
<p>Usage:</p>
<pre class="literal-block">
{% if wiki %}{% last_modified_pages wiki %}{% else %}{% last_modified_pages %}{% endif %}
</pre>
<p>Extended usage:</p>
<pre class="literal-block">
{% last_modified_pages wiki 20 %}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id5" id="pagelink" name="pagelink"><tt class="docutils literal"><span class="pre">pagelink</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">pagelink</span> <span class="pre">%}</span></tt></p>
<p>An inclusion tag, using the template <tt class="docutils literal"><span class="pre">wiki/tags/pagelink.html</span></tt>.
Renders the full hierarchical <cite>absolute qualified name</cite> for a page, with
subcompontents turned into links.</p>
<p>Receives two arguments, <tt class="docutils literal"><span class="pre">page</span></tt> (a <tt class="docutils literal"><span class="pre">Page</span></tt> instance) and <tt class="docutils literal"><span class="pre">no_terminal</span></tt>
(<tt class="docutils literal"><span class="pre">&quot;y&quot;</span></tt> or <tt class="docutils literal"><span class="pre">&quot;n&quot;</span></tt>).
The template context is populated with the variables <tt class="docutils literal"><span class="pre">wiki</span></tt>, <tt class="docutils literal"><span class="pre">chain</span></tt>,
<tt class="docutils literal"><span class="pre">no_terminal</span></tt> and <tt class="docutils literal"><span class="pre">do_terminal</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">wiki</span></tt> is the <tt class="docutils literal"><span class="pre">Wiki</span></tt> instance for the <tt class="docutils literal"><span class="pre">Page</span></tt>.
<tt class="docutils literal"><span class="pre">chain</span></tt> is the list containing the page hierarchy.
<tt class="docutils literal"><span class="pre">no_terminal</span></tt> is the boolean corresponding to the <tt class="docutils literal"><span class="pre">no_terminal</span></tt> parameter.
<tt class="docutils literal"><span class="pre">do_terminal</span></tt> is the opposite of <tt class="docutils literal"><span class="pre">no_terminal</span></tt>.</p>
<p>The final output could be something like:</p>
<pre class="literal-block">
&lt;a href=&quot;/Main&quot;&gt;Main&lt;/a&gt; | &lt;a href=&quot;/Main%7CRecipes&quot;&gt;Recipes&lt;/a&gt; . Lasagne
</pre>
<p>Usage:</p>
<pre class="literal-block">
{% pagelink page &quot;y&quot; %}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id6" id="wikilink" name="wikilink"><tt class="docutils literal"><span class="pre">wikilink</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">wikilink</span> <span class="pre">%}</span></tt></p>
<p>An inclusion tag, using the template <tt class="docutils literal"><span class="pre">wiki/tags/wikilink.html</span></tt>.
Renders the full hierarchical <cite>qualified name</cite> for a <tt class="docutils literal"><span class="pre">Wiki</span></tt>, with
subcompontents turned into links.</p>
<p>Receives two arguments, <tt class="docutils literal"><span class="pre">wiki</span></tt> (a <tt class="docutils literal"><span class="pre">Wiki</span></tt> instance) and <tt class="docutils literal"><span class="pre">no_terminal</span></tt>
(<tt class="docutils literal"><span class="pre">&quot;y&quot;</span></tt> or <tt class="docutils literal"><span class="pre">&quot;n&quot;</span></tt>).
The template context is populated with the variables <tt class="docutils literal"><span class="pre">chain</span></tt>,
<tt class="docutils literal"><span class="pre">no_terminal</span></tt> and <tt class="docutils literal"><span class="pre">do_terminal</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">chain</span></tt> is the list containing the wiki hierarchy.
<tt class="docutils literal"><span class="pre">no_terminal</span></tt> is the boolean corresponding to the <tt class="docutils literal"><span class="pre">no_terminal</span></tt> parameter.
<tt class="docutils literal"><span class="pre">do_terminal</span></tt> is the opposite of <tt class="docutils literal"><span class="pre">no_terminal</span></tt>.</p>
<p>The final output could be something like:</p>
<pre class="literal-block">
&lt;a href=&quot;/Main&quot;&gt;Main&lt;/a&gt; | Recipes
</pre>
<p>Usage:</p>
<pre class="literal-block">
{% wikilink wiki &quot;y&quot; %}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id7" id="wikimenu" name="wikimenu"><tt class="docutils literal"><span class="pre">wikimenu</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">wikimenu</span> <span class="pre">%}</span></tt></p>
<p>An inclusion tag, using the template <tt class="docutils literal"><span class="pre">wiki/tags/wikimenu.html</span></tt>.
Renders a hierarchycal menu with <tt class="docutils literal"><span class="pre">Wiki</span></tt> instances.</p>
<p>The tag is called recursively from the template to generate the menu tree.</p>
<p>It receives one optional argument, <tt class="docutils literal"><span class="pre">current</span></tt> (a <tt class="docutils literal"><span class="pre">Wiki</span></tt> instance), and other
<cite>service</cite> variables used to handle the recursion.
The template context is populated with the variables <tt class="docutils literal"><span class="pre">current</span></tt>, <tt class="docutils literal"><span class="pre">wikis</span></tt>,
<tt class="docutils literal"><span class="pre">images</span></tt>, <tt class="docutils literal"><span class="pre">folderopen</span></tt>, and <tt class="docutils literal"><span class="pre">folder</span></tt> (and other <cite>service</cite> variables).</p>
<p><tt class="docutils literal"><span class="pre">current</span></tt> is the currently selected <tt class="docutils literal"><span class="pre">Wiki</span></tt>, or <tt class="docutils literal"><span class="pre">None</span></tt>.
<tt class="docutils literal"><span class="pre">wikis</span></tt> is the list of <tt class="docutils literal"><span class="pre">Wiki</span></tt> instances at the current recursion level.
<tt class="docutils literal"><span class="pre">images</span></tt> is the image path on the server.
<tt class="docutils literal"><span class="pre">folderopen</span></tt> is the open folder icon.
<tt class="docutils literal"><span class="pre">folder</span></tt> is the close folder icon.</p>
<p>Usage:</p>
<pre class="literal-block">
{% if wiki %}{% wikimenu wiki %}{% else %}{% wikimenu %}{% endif %}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id8" id="wikis" name="wikis"><tt class="docutils literal"><span class="pre">wikis</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">wikis</span> <span class="pre">%}</span></tt></p>
<p>An inclusion tag, using the template <tt class="docutils literal"><span class="pre">wiki/tags/wikis.html</span></tt>.
Renders the list of the most recently created wikis.</p>
<p>It receives one optional argument, <tt class="docutils literal"><span class="pre">num</span></tt> (default is 30), which specifies how
many objects to return.
The template context is populated with the variable <tt class="docutils literal"><span class="pre">wikis</span></tt>, containing the
list of <tt class="docutils literal"><span class="pre">Wiki</span></tt> instances.</p>
<p>Usage:</p>
<pre class="literal-block">
{% wikis %}
</pre>
</div>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id9" id="filter-reference" name="filter-reference">Filter reference</a></h2>
<div class="section">
<h3><a class="toc-backref" href="#id10" id="in-list" name="in-list"><tt class="docutils literal"><span class="pre">in_list</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">in_list</span> <span class="pre">%}</span></tt></p>
<p>Returns a boolean indicating if its first argument is present in its second
argument (typically a list or a tuple).</p>
<p>Usage:</p>
<pre class="literal-block">
{% if user|in_list:cool_people %}You're cool!{% else %}Don't lose hope :-){% endif %}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id11" id="sanitize" name="sanitize"><tt class="docutils literal"><span class="pre">sanitize</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">sanitize</span> <span class="pre">%}</span></tt></p>
<p>Returns a <em>sanitized</em> version of its argument, with dangerous HTML code
removed. Non dangerous tags (<tt class="docutils literal"><span class="pre">&lt;p&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;i&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;strong&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;b&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;u&gt;</span></tt>,
<tt class="docutils literal"><span class="pre">&lt;h1&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;h2&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;h3&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;pre&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;br&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;a&gt;</span></tt>, <tt class="docutils literal"><span class="pre">&lt;img&gt;</span></tt>), are left
in place. For <tt class="docutils literal"><span class="pre">&lt;a&gt;</span></tt> and <tt class="docutils literal"><span class="pre">&lt;img&gt;</span></tt> tags, the <tt class="docutils literal"><span class="pre">href</span></tt> attribute is stripped off
inline Javascript code, if any.</p>
<p>Usage:</p>
<pre class="literal-block">
{{ user_text|sanitize }}
</pre>
</div>
<div class="section">
<h3><a class="toc-backref" href="#id12" id="wiki" name="wiki"><tt class="docutils literal"><span class="pre">wiki</span></tt></a></h3>
<p><tt class="docutils literal"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">wiki</span> <span class="pre">%}</span></tt></p>
<p>Renders a <tt class="docutils literal"><span class="pre">PageContent</span></tt> text, parsing the <a class="reference" href="syntax.html">wiki syntax</a>.</p>
<p>Usage:</p>
<pre class="literal-block">
{{ pagecontent|wiki }}
</pre>
</div>
</div>
</div>
</div>
</body>
</html>
