Documentation Topics¶
The example code described in the following chapters can be found in the
source distribution in the docs/examples/
folder. It’s also
available online and listed in the example index.
Basic Templating¶
Template Annotations¶
TDI strictly keeps the template and the rendering logic apart. That way you can write your, say, HTML template in HTML and your logic in a real language - python in this case. There is no template language in-between. You just need to label the locations in the template which should be modified later. More...
Simple Content Editing In Python¶
The counterpart of the template is the rendering logic written in python. TDI expects a so-called “model” object here, which provides callback methods for the modifiable nodes. Content manipulations are escaped automatically and unicode-aware. More...
Plain Text Templates¶
Plain text – naturally – does not provide any markup by itself. TDI accepts some simple markup, which can be used to annotate your text templates. More...
Looping¶
Looping is basically about repeating a template block and filling each
repeated item differently. There are two ways of looping:
→ node.iterate()
and
→ node.repeat()
. More...
Code Organization¶
Template Combination With Overlays¶
Usually there’s more than one template in a project and there are certainly the same or similar elements on the different pages. In order to avoid code duplication move the common elements into an extra file and load them where they are needed. TDI provides the concept of overlays for this purpose. More...
Helpful Tools¶
TDI comes with a set of tools that provide solutions for various common tasks and have been proven useful in practice.
Miscellaneous HTML Tools¶
The tools described here can be found in the → tdi.tools.html
module. It contains node manipulation helpers and tools for encoding,
decoding and minifying HTML. More...
HTML Form Tools¶
Since TDI provides you with such neat node objects, it’s pretty easy to write generic functions to handle certain kinds of nodes. HTML forms always require a huge effort to get them right and are such a common use case that TDI comes with a ready-to-use abstraction of those particular (and peculiar) kind of nodes. More...
Javascript Tools¶
The tools described here can be found in the → tdi.tools.javascript
module. The module deals a lot with safe javascript manipulation and
provides also a minifier. More...
CSS Tools¶
The tools described here can be found in the → tdi.tools.css
module. The CSS tools mainly provide a minifier for now. More...
Template Tools¶
The → tdi.tools.template
module deals with templates on a higher
level and can help you organizing your template lists.
More...
Advanced Features¶
Partial Rendering¶
Modern websites often (re-)load parts of the page using javascript. TDI attempts to help you somewhat with such demands. It provides the possibility to render only a subnode of the template. More...
Pre-Rendering¶
Often some parts of a webpage are more dynamic than others. TDI lets you render the less dynamic parts independently from the hot stuff. More...