The template syntax can formally be defined as follows:
TEMPLATE = BLOCK [ BLOCK ... ] BLOCK = { HDU | GROUP } GROUP = \GROUP [ BLOCK ... ] \END HDU = XTENSION [ LINE ... ] { XTENSION | \GROUP | \END | EOF } LINE = [ KEYWORD [ = ] ] [ VALUE ] [ / COMMENT ] X ... - X can be present 1 or more times { X | Y } - X or Y [ X ] - X is optional
At the topmost level, the template defines 1 or more template blocks. Blocks can be either HDU (Header Data Unit) or a GROUP. For each block the parser creates 1 (or more for GROUPs) FITS file HDUs.