6. Configuration and examples

6.1. Tags configuration

The format of tags in a template, together with other settings, can be configured by the BlockConfig configuration object.

The configuration object attributes define the format of template tags using functions defining how a template tag string is generated from a tag name. The most straightforward way to define these tag generators is to use the lamba functions.

The tabulator size attribute is used by the alignment autotag when tabulators are used for the alignment.

The block configuration can be modified by the Block.config attribute. Alternatively, a BlockConfig object can be created and set as an attribute to the Block object constructor or assigned to the Block.config attribute.

All child Block objects use the same configuration as their parent block.

A simple demo function using the custom tag format configuration can be found in the examples listed in the following section.

6.2. Examples

The demo_advanced.py file in the samples directory provides various examples that should serve as an additional source of information and inspiration for further experimentation.

The most important demo functions are:

  • General examples

    • demo_shoplist_advanced: A shopping list generated using most of the data-driven filling features.

    • demo_shoplist_advanced_custom_cfg: A shopping list generated from a template using custom tag format configuration.

  • Custom feature extensions implemented using the fill handler with manual filling methods

    • demo_macros_1 and demo_macros_2: Template macros, i.e., template blocks referenced in multiple places in the template and filled with different data.

    • demo_extensions_1 and demo_extensions_2: Template extensions, i.e., modification of existing template blocks using other custom extension blocks.