Template semantics
A template consist of JSON entities which are evaluated recursively on some input queryset available as $ to SakStig expressions. Initially, the template context @template() is set to the same as $. The output is a queryset.
The template is an object
If the template contains a member named $
- The value of
template.$is evaluated as a SakStig expression to form aninputqueryset. - If the template does not contain any other members than
$,inputis returned and evaluation ends. - Each
inputentry is transformed to form a new queryset which is returned.
input entry transform:
@templateis set to a queryset containing only the currentinputentry.- A new empty
outputobject is created. - For each
memberof the template:member.valueis evaluated recursively as a template to form avaluequeryset. - Ifvalueis the empty queryset, the member is ignored.output[member.name]is set to the first entry in thevaluequeryset.
If the template does not contain a member named $
- A new empty
output_objectis created - For each
memberof the template: -member.valueis evaluated recursively as a template to form avaluequeryset. - Ifvalueis the empty queryset, the member is ignored. -output_object[member.name]is set to the first entry in thevaluequeryset. output_objectis returned as a single member of a queryset.
The template is an array
- Each array member is evaluated recursively as a template.
- All the resulting querysets are concatenated and converted into a JSON array which is returned as a single member of a queryset.
Other values
All other values are returned verbatim as a single member of a queryset.