Expressions - Strings

Depending on the particular software application you are using, it might not be possible to change your data before sending it to Docmosis.

Docmosis has a range of string functions you can use within the templates to modify and format your data and achieve the desired result in your generated documents.


To understand the functions in this example, you may find it helpful to download the supplied and view the example template together with the output file.

Working with strings

Fixed or static strings in your templates should be formed using single quotes.

For example: <<cs_{gender='male'}>> This person is a Male. <<es_>>

In the above example, 'male', is a fixed string that is being used for comparison in the <<cs_ conditional section.

Text functions

Docmosis has many text functions, for example changing case, determining text length, or replacing strings.

Changing case

Your input data can be easily case-converted using built-in functions like:

toLowerCase the resulting sentence will be all lower case
titleCase The Resulting Sentence Will Be In Title Case

For the full list of text functions, refer to the "Text Functions" section in the Template Guide.

Logic and transform functions

Docmosis also has expression syntax for supporting general functions, such as determining if an element is blank, or mapping data, that are also useful for manipulating text.

Mapping your data

With Docmosis you can "map" your input data to the desired output.

For example, this:

<<{map(toUpperCase(gender), ‘M’, ’Male’, ‘F’, ‘Female’, ‘Other’)}>>

will achieve this:

Input Data Desired Output
f Female
(all other letters) Other 

For the full list of logic and transform functions, refer to the "Logic and Transform Functions" section in the Template Guide.

Using list data in a sentence

The example template shows how to loop through a list of values and use them in a comma-separated sentence like the one shown below.

Input Data:

"apples", "bananas", "oranges"

Desired sentence in finished document:

"My favorite fruits are apples, bananas and oranges."

The challenge is to insert a comma between values, except for the last two, and to insert the word "and" between the last two values.

To achieve this result in Docmosis, use an <<rs_ repeating section, a <<cs_ conditional section, and the built-in Docmosis variables, $itemnum and $size, as explained in the example template.


Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input