Template Factory Implementation Details

The factory parameters determine, which parser to use, which tree builder, if and how the templates should be filtered and so on. Some of the parameters depend on others. The list of parameters represents a comprehensive mix of interfaces which are expected in order to combine all the components properly.

Before explaining those interfaces, let’s see what actually happens with the stuff passed in. When loading a template using a factory’s method (e.g. → from_file) the following actions are taken:

  1. The filters are initialized.
  2. The tree builder is initialized with the filters.
  3. The parser is initialized with the tree builder.
  4. The file is opened and the stream is fed to the parser.
  5. The parser emits events to the tree builder (possibly modified by the filters).
  6. The stream is finished.
  7. The parser is finished.
  8. The tree builder is finished and asked for the generated node tree.
  9. The tree is stuffed into a fresh template object (among other things).
  10. If autoloading is requested, the template is wrapped into the autoloader proxy object.
  11. The template object is returned.

If memoization is enabled, the whole chain of actions is prepended by a check if the key is already stored in which case only the template object is returned. If the key is not found in the memoization storage container, all actions are taken and the template object returned in the last step is stored for the next call.

Basic Data Flow

WRITEME.

Main Interfaces

Stream Opener

Stream Open

Table Of Contents