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.
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...
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 – naturally – does not provide any markup by itself. TDI accepts some simple markup, which can be used to annotate your text templates. More...
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...
TDI comes with a set of tools that provide solutions for various common tasks and have been proven useful in practice.
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...
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...
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...
The tools described here can be found in the → tdi.tools.css module. The CSS tools mainly provide a minifier for now. More...
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...
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...
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...