Documentation:

Functions that may be applied to variablesΒΆ

Often, a variable cannot be used as-is, but needs to be processed slightly.

For example, before a text string can be inserted into PHP, possible quotes in the text string need to be escaped. If a blogging app defines a Customization point called title, and a user provides the value Bob's Greatest in their Site JSON for it, a hypothetical PHP configuration file for this app configuration should read as follows:

$blogTitle = 'Bob\'s Greatest';

to avoid syntax errors. To accomplish this, the developer would use the following line in their template file:

$blogTitle = '${escapeSquote( installable.customizationpoints.title.value) }';

instead of:

$blogTitle = '${installable.customizationpoints.title.value}';

See also Variables available at deploy or undeploy.

Note

Currently, the implementation of functions on those variables is rudimentary. Only a single function may be used; they may not be nested or concatenated.

The following functions are currently available:

escapeSquote
Prepend all single quotes in the string with a backslash, so abc'def becomes abc\'def. This is useful in configuration files where values need to be specified as quoted strings, e.g. in PHP.
escapeDquote
Prepend all double quotes in the string with a backslash, so abc"def becomes abc\"def. This is useful in configuration files where values need to be specified as quoted strings, e.g. in PHP.
trim
Trim leading and trailing white space from a string.
cr2space
Convert all newlines to spaces. This is useful to convert a multi-line string into a single-line string.