Fields - Formatters

You can use special formatters for Fields and Smart Fields

Quick examples:

{field | toFixed:2} > Sets number decimal precision 5300.1 > 5300.10
{field | format:2:',':'.'} > Sets number decimal precision, thousand separator, decimal separator e.g.  5300.1 > 5,300.00
{field | round:2} > Sets number decisal precision and it rounds up value to specific precision e.g. 5300.5783 > 5300.58
{field | inWords:'en'} > Spells Number in words based on selected language 5300.1 > five thousand three...
{field | date:'de-DE':'Europe/Berlin'} > Formats Date in specific format and timezone
{field | time:'en-US':'America/New_York'} > Formats Time in specific format and timezone
{field | uppercase } > Sets text uppercase e.g. "TEST"
{field | lowercase } > Sets text lowercase e.g. "test"
{field | capitalize } > Capitalize first letter of text e.g. "Test"

Special Field formatter “format”

If you want format number that reflect money in some specific world format you can do that using format filter. It will allow you set following parameters:

  • decimal points (default: 2)

  • thousands delimiter (default: ',')

  • decimal delimiter (default: '.')

[fieldName] | format:[decimalPoints]:"[thousandDelimiter]":"[decimalDelimiter]"

{field} > 5300.1
{field | format} > 5300.1 > 5,300.10
{field | format:3} > 5300.1 > 5,300.100
{field | format:2:'.':','} > 5300.1 > 5.300,10
{field | format:2:'-':','} > 5300.1 > 5-300,10
{field | format:4:' ':'.'} > 5300.1 > 5 300.1000

Special Field formatter “toFixed”

It’s pretty common that you need to calculate the field and see the output in specific precision (especially if you calculate price/cost in some currency).

E.g. If the result of the calculation are 1.54212 > the output will be converted to 1.54. It's a simplified format function. If you want to round numbers to specific precision use the "round" filter instead.

{field} > 5300.1
{field | toFixed} > 5300
{field | toFixed:2} > 5300.10
{field | toFixed:3} > 5300.100
{field | toFixed:0} > 5300

{field2} > 499.997
{field2 | toFixed} > 499
{field2 | toFixed:2} > 499.99

Special Field formatter “round”

This filter works in a similar way as "toFixed" however it rounds up value to specific precision

{field} > 5300.1
{field | round} > 5300
{field | round:2} > 5300.10

{field2} > 499.997
{field2 | round} > 500
{field2 | round:2} > 500

{field3} > 5.56789
{field3 | round} > 6
{field3 | round:2} > 5.57

Special Field formatter “inWords”

It’s quite common that you need your value being spelled in words on your document

{field} > 501
{ field | inWords: 'en'} > five hundred and one
{ field | inWords: 'pl'} > pięćset jeden

More Advanced Example:
{price} USD > 149.99 USD
{$ price | format:0 | inWords:'en'} dollars and {$ price % 1 * 100 | format:0 | inWords:'en'} cents > one hundred and forty-nine dollars and ninety-nine cents

E.g. If results value is 4500, output will be converted to “four thousand and five hundred”

Let’s apply this to example above to get proper USD values:

By Default inWords is set to English but it support following languages:

  • en (English, default)

  • ar (Arabic)

  • cz (Czech)

  • dk (Danish)

  • de (German)

  • es (Spanish)

  • fr (French)

  • fa (Farsi)

  • he (Hebrew)

  • hu (Hungarian)

  • id (Indonesian)

  • it (Italian)

  • ko (Korean)

  • lt (Lithuanian)

  • lv (Latvian)

  • nl (Dutch)

  • no (Norwegian)

  • pl (Polish)

  • pt (Portuguese)

  • ru (Russian)

  • sr (Serbian)

  • tr (Turkish)

  • uk (Ukrainian)

  • zh (Chinese)

Special Field formatter "date", "time"

You can display provided time or date in format you desire in output document (if Date is provided in format that could be parsed).

It supports two optional parameters:

{ field | date:'[format]' : '[timeZone]'}

{ field | time:'[format]' : '[timeZone]'}

format [optional] - output format using language code (12 hours vs 24 hours etc.) - Examples: en-US, en-GB, fr-FR, de-DE, pl-PL, es-ES, it-IT | Default: 'en-US'

timeZone [optional] - timezone in Intl format - Examples: America/Chicago, Europe/Berlin, Europe/Warsaw, Europe/Rome | Default: 'Universal' UTC Timezone See list of Available Timezones:

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Examples for date:

{field} ---> 4/28/2023
{field | date:'en-US'} --->  4/28/2023 
{field | date:'de-DE'} --->  28.4.2023 
{field | date:'de-DE':'Europe/Berlin'} --->  28.4.2023

If incorrect format / timezone will be provided Documentero will use default values.

Special Field formatter "capitalize", "uppercase", "lowercase"

You can use one of "capitalize", "uppercase", and "lowercase" filters if you want to change the formatting of text to uppercase or lowercase. You can make only first letter uppercase using capitalize. Check examples below:

{ field }  > teSt

{ field | uppercase } > TEST
{ field | lowercase } > test
{ field | capitalize } > TeSt

Special Field formatter “hide"

You can use "hide" filter if you want to hide field output on regular field. Useful if you need to use field value withing Smart Fields or Smart Sections but you don't want to show actual value in the document

{field | hide}
Field will be defined in document structure but nothing will be visible in the document

{#$ field == "Yes"}
This part of document will apear if field equals Yes
{/}
You can use field within Smart Sections

{$ field == "Yes" ? "TextIfYes" : "TextIfNo" }
You can use field within Smart Fields

Last updated