Velocity is a powerful language that allows you interact with your data in sophisticated ways, using directives like:
#if($condition) ... #else ... #end
#foreach($item in $list) ... #end
#set($variable = "value")
Velocity can also interact with APIs that are passed into their context, for example the PocketQuery Velocity API. We highly recommend reading the VTL reference and our Templating Tutorial if you want to learn how to effectively use Templates.
If you want to see a short example of how Templates can be used, have a look at this part of our Getting Started guide.
If you don’t specify a Template yourself, PocketQuery will use this Template to render your query result into HTML. This is also the code that will be inserted into your editor if you hit the “Insert Example Code” button.
#set($tableRows = $PQ.toList($result)) #set($tableHeaders = $tableRows.get(0).keySet()) <table class="aui"> <thead> <tr> #foreach ($header in $tableHeaders) <th>$!header</th> #end </tr> </thead> <tbody> #foreach ($row in $tableRows) <tr> #foreach ($column in $row) <td>$!column</td> #end </tr> #end </tbody> </table>
If you are interested in resource limits related to Templates, check out this article.