The Default Template
The default template of PocketQuery produces a simple Confluence table:
![](../__attachments/824410137/Screenshot_2020-10-20%20Population%20-%20admin%20-%20Confluence.png?inst-v=1527abee-7a84-47e9-9034-81915ed62bd3)
The table has two columns Name and Population, according to the SELECT clause of the query. You can change this appearance with a custom template.
Templates for PocketQuery are written in Velocity, a Java templating language. Let’s have a look at the code of the default PocketQuery template that is selected by default for all queries.
<table class="aui confluenceTable pocketquery-table">
<thead>
<tr>
#foreach ($column in $columns)
<th class="confluenceTh">$!column</th>
#end
</tr>
</thead>
<tbody>
#foreach ($row in $result)
<tr>
#foreach ($column in $row)
<td class="confluenceTd">$!column</td>
#end
</tr>
#end
</tbody>
</table>
There is one loop for the header that runs through the column names and one loop (with another nested loop) running through the result. Note that the variables $columns
and $result
are passed to any PocketQuery template, so you can use them as you please. For a more formal specification of what kind of objects are available in PocketQuery templates, see Velocity API Available In Templates.
Continue with “Custom CSS To Highlight Particularly High/Low Values“