Skip to content

Templates

Matt Krins edited this page Apr 17, 2024 · 33 revisions

About

Templates are used to build dynamic paths, names, strings, etc. based on the current connector being consumed.
PlatySync uses the Handlebars templating language, and as such any helpers and logic which is provided by Handlebars will be available in PlatySync templates.
Most fields, such as in the conditions builder & various actions you will see the following icon: image
This icon denotes the field can use the templating language. Clicking on the icon will open the Template Explorer.

Notes

  • Handlebar template HTML-escaping has been disabled by default. If you wish to escape HTML to transform special characters such as & <, etc. into &amp; &lt; etc, then you will need to use the $escape custom helper.

Custom Helpers

PlatySync provides a number of pre-built custom helpers which can be used. Examples provided.

  • $upper: Converts the input to uppercase.
    {{$upper 'HELLO world'}} > HELLO WORLD
  • $lower: Converts the input to lowercase.
    {{$lower 'HELLO world'}} > hello world
  • $title: Converts the input to title case (first letter of each word capitalized).
    {{$title 'HELLO world'}} > Hello World
  • $cap: Capitalizes the first letter of the input.
    {{$cap 'hello world'}} > Hello world
  • $clean: _ Removes extra whitespaces and newline characters from the input._
    {{$clean 'hello \n world \n'}} > hello world
  • $inc: Increments a numeric value by 1.
    {{$inc '2'}} > 3
  • $grad: Converts a numeric value to a graduation year.
    {{$grad '7'}} > 2029 (if run in 2024)
  • $find: Searches for the substring. Returns true if found, false otherwise.
    {{$find 'haystack' 'needle'}} > false
  • $rand: Generates a random integer between the specified range (inclusive).
    {{$rand 1 9}} > 5
  • $special: Generates a random special character from the set '!?$%&*)>'.
    {{$special}} > %
  • $word: Retrieves a random word from the dictionary.
    {{$word}} > bread
  • $escape: Escapes special characters in the input string.
    {{$escape '& <'}} > &amp; &lt
  • $dir: Prints working directory of platysync.
    {{$dir}} > C:\Users\user\AppData\Roaming\platysync

Examples

  • Generate a user password
    Template: {{$word}}{{$rand 1 9}}{{$cap ($word)}}{{$special}}
    Outputs: hello5What$, this2Cat&, blue9Tame#

PDF Templates

Similar to PlatySync templates, when using the Write PDF action, PDFs can be generated and filled using templates.
PDF templates utilize the Adobe Form system.
To dynamically enter data from your entry/connector, create a new form field and set the name to the template needed.
image image

Template Explorer

The Template Explorer helps build template strings showing data available to use from connectors, files, actions and helpers.
image
Only connectors which have been added to the rule will be shown. If you do not see a connector, you may need to add it.
Selecting a connector will show the headers/columns available for use. Select one insert into the field:
image image
Select Files to add an uploaded file. This template will be replaced with the OS directory path to the file.
image
To create more advanced templates, or format text, you may want to use a helper.
image

Files

The file manager can be used to add static data into PlatySync.

image

For example, you may want to upload a templated PDF to the file manager.
Once a file is updated, you can access it within handlebar templates like such: {{$file.fileName}}