The extension provides the option to format an APE template document applying code indentation rules.
Indentation detection
By default, the Visual Studio Code editor is configured to detect a file's indentation type when it is opened. A file's indentation is defined by the character used, i.e. tabulation or space. If the indentation character is a space, a number of spaces defines the "size" of the indentation.
Indentation detection (when opening an existing file), indentation character and number of spaces (when creating a new file) are configured in Visual Studio Code of in the editor settings (via the command palette for example).
The indentation settings for a file (open in the editor) can be changed via the status bar:
Play video in media player ↑ Top of page
Source code formatting
Code formatting assumes that the code written is syntactically correct.
Like tag languages, ">" and "<" are reserved characters. They are used to delimit a call to a tag and are also comparison operators. To do this, it is strongly recommended that they are used as follows:
- When used as a comparison FreeMarker operator, use the equivalent operators "gt", "gte", "lt" and "lte" in place of ">", ">=", "<" and "<=" respectively;
- When used as a character in an alphanumeric string, use escape characters "\g" and "\l" in place of ">" and "<" respectively.
FreeMarker also allows the use of opening language instruction tags without the associated closing tags (e.g. <#if> ... <#else> ... </#if>). When <#assign>, <#else>, <#elseif>,<#break>, <#case>, <#default>, <#continue>, <#fallback>, <#flush>, <#global>, <#import>, <#include>, <#local>, <#lt>, <#nested>, <#nt>, <#recurse>, <#return>, <#rt>, <#setting>, <#stop>, <#t>, <#visit> tags are used without their closing tag, they must be called like self-closing tags (e.g. <#else />, <#elseif />, <#break />, etc.).
Only <#recover>, <#case> and <#default> tags must be used without end tags.
Formatting is based on indentation rules defined in Visual Studio Code extension for editing APE templates. The rules can be modified locally for a project (workspace scope) or globally for the user (user scope).
Document formatting is triggered by selecting the "Format Document" command via the context menu (right-click with the mouse) in the document text editor:
Play video in media player ↑ Top of page