Template

Template uses an advanced, yet simple, template system to allows you to create and modify the content to be copied to the clipboard. The syntax is really straight-forward and consists of the following categories;

Simple Tag

Tags are always surrounded by curly braces like this {name} and output the value of the named variable. If that value is undefined or falsey it will simply be deleted.

Values are not escaped by default and, in order to do so, you must either use double braces like {{name}} or a leading ampersand like {&name}. This will escape & < > " ' characters so that the final output can be safely copied in to XML and HTML.

Section

Sections are always surrounded by opening and closing tags like this {#name}...{/name} and can be used for the following purposes;

  • Conditions - Only renders the contents if the value is truey
  • Iterating - If the value is an array it will render the contents for each enumerable item of that value
  • Access - If the value is an object it will render the contents while exposing the properties of that object as variables
  • Operations - Renders the outcome of the operation, passing the contents as the argument

Inverted Section

Inverted sections are very similar to normal sections but are written like this {^name}...{/name} and can be used in for the following purposes;

  • Conditions - Only renders the contents if the value is falsey
  • Iterating - Only renders the contents if the value is an empty list
  • Access - Only renders the contents if the value is an empty object

Dot Notation

Nested properties of objects can also be accessed using dot notation like {name.nested} which would get the nested property of the name object. These expressions can be even chained to access properties of nested properties and so on.

Case Sensitivity

The names of simple tags and sections are case-insensitive, therefore {name} will output the same as {NaMe}. However, sections must be opened and closed with names in the same case (i.e. {#name}...{/NaMe} will not work).

Notes

If you are having problems with understanding this guide please let us know and we will try to help you and take your comments on board, updating the documentation if required.

If you encounter any problems while using Template and/or would like to see a change or addition, please raise a ticket and we will have a look at it.

For more examples, try looking at the predefined templates.