AppyPrinciplesGetting started
appy.pod Writing ODT templates The « minus » operator

Warning - Read the previous section before reading this one.

The example of the previous section introduces the repetition of a section within a POD template. To tell the truth, the base section that was defined in the example POD template was there for the sole purpose of adding a POD statement to it, in order to repeat it. In other words, this section was completely useless, excepted for "structural" reasons, required by POD. Your sense of perfection could have noticed that it's a pity to have, in the POD result, three resulting sections. A better solution would have been to produce a result without any section anymore, only made of the content of the three sections, rendered sequentially without their enclosing section.

This is exactly what the minus operator does.

Instead of writing the statement as:

do section
for group in groups

Use the minus operator that way:

do section-
for group in groups

It tells POD to take care of the section's content only, without dumping the enclosing section itself in the POD result. As an exercise, reexecute the example from the previous section, using this minus operator, and check the differences between the obtained result and the one produced without applying this operator.

When defining complex POD templates, such "structurally added" elements may be numerous in your POD template, and included in each other, like Russian dolls. At the time POD was created, LibreOffice did not allow sections to be included in other sections. So POD allowed to apply the minus operator to one-cell tables as well. In the early POD era, you defined a complex structure that way: section > one-cell-table > one-cell-table.... Now, you can define sections being included in other sections. Whatever technique you choose, be sure to apply the minus operator correcly:

  • wherever it is required (to avoid having an "over-structured" POD result);
  • to sections and one-cell-tables only.

Moreover, producing over-structured POD results may lead to errors, most notably if the ODT result is then converted to Microsoft Word via LibreOffice running in server mode.

If you try to apply the minus operator to, for example, a table containing more than one cell, POD will complain and produce an error.

This is the case on this example.

If you try to produce a POD result with this template, an error will be produced.

By the way, this is a forward reference: you just discovered how errors are rendered by default within POD results.

So, you may correct the template to produce this one.

Rendering it with a context where variable persons is a list of 8 persons can now produce an error-free result, like the one shown below.

I have chosen this example to illustrate yet another issue: use the minus operator only if you don't care about any formatting associated with the table or section to remove. In the above example, using it could not have been the right choice if we wanted to print those addresses on envelopes.