Expressions - Strings

Category : Technical Examples

Depending on your particular software application it may 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 format your data and achieve the desired result in your generated documents.

Data Files

Output Files

All Files as a ZIP

It is best to view the TEMPLATE and OUTPUT files side-by-side to understand the functions and their effect.


This example shows

1) Working with Strings

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

    <<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 Conditional Section.


2) Changing Case

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

toLowerCase :  the final sentence will be all lower case
titleCase :  The Final Sentence Will Be In Title Case

For a full list of String functions see the Quick Reference download link below.


3) 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
F Female
m Male
M Male
(all other letters) Other


4) Displaying List Data in Sentences

The example template shows how to loop through a list of values and display them in a comma separated sentence like this:

Input Data:

    "apples", "bananas", "oranges".

Desired sentence in finished document:

    My favorite fruits are apples, bananas and oranges.


The challenge is to include just enough "commas" and finish the sentence with an "and".

By using a combination of looping/testing/built-in-variables, this type of output can be achieved with Docmosis.

TRY: Changing the number of "fruit" in the data to see the effect in the finished document.


LEARN MORE: Download our Docmosis Quick Reference [PDF].