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...
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...
Copy & Replace¶
These node operations are less frequently used than all the others, but nevertheless useful. Common use cases are content picking or building trees. More...
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...
TDI comes with a set of tools that provide solutions for various common tasks and have been proven useful in practice.
Miscellaneous HTML Tools¶
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...
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...
TDI allows modifying and extending its parser events before they reach the tree builder. Since these filters are applied at loading time, they have no performance impact during rendering. More...