Log in

You have encountered now every possible POD statement. All the examples proposed so far have presented a single statement per LibreOffice comment. If we stick to this logic, writing complex POD templates may rapidly become a headache.

Let's illustrate this with an example.

Suppose you have built a piece of software for managing (very simple) medical files. Every medical file is composed of:

  • basic metadata about the patient: its name, address,...
  • a series of binary files, every file being typed: x-ray, consultation report, blood analysis, etc.

You want your software to be able to produce a single PDF file containing, for a given patient, all the metadata; plus, optionally (if chosen from your software user interface), binary files of type report.

Armed with your knowledge of POD, you could produce the following POD template. The complete medical file for the currently selected patient is passed to the template as variable named self. Boolean variable includeReports is also in the context, being True if reports must be included as well.

This example has the following structure.

  • In order to include or not the binary files, depending on boolean variable includeReports, a section is created, associated with a if statement.
  • Within this section, a one-cell table is added, just for adding one more statement, a for statement looping over all medical files defined for a patient.
  • Within this table, I have added one more table in order to associate a with statement to it, to easly access the binary file's type.
  • Then, one more one-cell table is added to conditionally include the file if it has the right type.
  • Finaly, a statement is used to inject the file by using the document function.

In this example, even if some statements are not strictly needed (the with statement could be removed here, but could be requested if the POD template was more complex), ODT elements like sections and/or one-cell tables have been artificially added to the POD template for the sole purpose of defining statements. Although this over-structure can be removed from the ODT result via the use of the minus operator, this still produces a complex and hardly maintainable POD template.

This is where multi-statements come into play. It is possible to group several statements in a single LibreOffice comment. The previous example can be rewritten with a single statement, like shown below.

When writing multi-statements, keep in mind the following.

  • The first line, starting with "do ...", MUST contain the first statement. The following statement is illegal:
do text
if ...
for ...
  • Every sub-statement can use variables defined by previous statements from the same multi-statement.
  • There must be a single sub-statement per line in the comment. A sub-statement cannot be spread on several lines.
  • A single from clause can be defined per comment and, like sub-statements, cannot be spread on several lines.