<h1><aname="rendering"></a>Rendering a pod template</h1>
<p>In order to render a pod template, the first thing to do is to create a renderer (create a <spanclass="code">appy.pod.Renderer</span> instance). The constructor for this class looks like this:</p>
<p>For the <spanclass="code">template</span> and the <spanclass="code">result</span>, you can specify absolute or relative paths. I guess it is better to always specify absolute paths.</p>
<p><br/>The <spanclass="code">context</span> may be either a dict, UserDict, or an instance. If it is an instance, its <spanclass="code">__dict__ </span>attribute is used. For example, <spanclass="code">context</span> may be the result of calling <spanclass="code">globals()</span> or <spanclass="code">locals()</span>. Every (key, value) pair defined in the context corresponds to a name (the key) that you can use within your template within pod statements or expressions. Those names may refer to any Python object: a function, a variable, an object, a module, etc.</p>
<p>Once you have the <spanclass="code">Renderer</span> instance, simply call its <spanclass="code">run</span> method. This method may raise a <spanclass="code">appy.pod.PodError</span> exception.</p>
<p><br/>Since pod 0.0.2, you may put a XHTML document somewhere in the context and ask pod to convert it as a chunk of OpenDocument into the resulting OpenDocument. You may want to customize the mapping between XHTML and OpenDocument styles. This can be done through the <spanclass="code">stylesMapping</span> parameter. A detailed explanation about the "XHTML to OpenDocument" abilities of pod may be found <ahref="podWritingAdvancedTemplates.html#xhtml">here</a>.</p>
<p>If <spanclass="code">result</span> ends with <spanclass="code">.odt</span>, LibreOffice will NOT be called (unless <spanclass="code">forceOoCall</span> is <spanclass="code">True</span>). pod does not need LibreOffice to generate a result in ODT format, excepted in the following cases:</p>
<li>you need to update fields in the result (ie a table of contents);</li>
<li>you need to include external documents into the result (ODT, PDF, Word, ...) by using special function <ahref="podWritingAdvancedTemplates.html#document"><spanclass="code">document</span></a>.</li>
<p>LibreOffice will be called in order to convert a temporary ODT file rendered by pod into the desired format. This will work only if your Python interpreter knows about the Python UNO bindings. UNO is the OpenOffice API. If typing <spanclass="code">import uno</span> at the interpreter prompt does not produce an error, your interpreter is UNO-enabled. If not, there is probably a UNO-enabled Python interpreter within your LibreOffice copy (in <LibreOfficePath>/program). In this case you can specify this path in the <spanclass="code">pythonWithUnoPath</span> parameter of the <spanclass="code">Renderer</span> constructor. Note that when using a UNO-disabled interpreter, there will be one additional process fork for launching a Python-enabled interpreter.</p>