Data templates transform the data model into text or HTML content. Templates are used in many areas in emakin like form controls or mail templates etc.
...
All text or string types are exactly transformed without any formatting being performed.
On the other hand, if a string node's value is actually a number, it automatically displays thousand separator dots.
To avoid this, pass 'string' as second argument to format function as below:
Code Block | ||||
---|---|---|---|---|
| ||||
{{ format( 'Employee/RegistryNumber', 'string' ) }} |
By default template values are not automatically formatted but Label like controls automatically formats the number like values. You can use format string to disable auto formatting.
Examples
...
...
Number formatting
Functions like "Sum" or "Count" already return number values, therefore there is no need for number conversions, but in case it is necessary, number() function should be used. Ex: number(MyNumberField)
...
Template | Outputs | Culture | |
---|---|---|---|
{{ MyDate }} | 01/31/2014 16:04:12 +02:00 | ||
{{ format(MyDate,'MMM/yyyy/dd') }} | Feb.2018.04 | ||
{{ format(MyDate,'MMM/yyyy/dd') }} | Şub.2018.04 | tr-TR | |
{{format(MyDate, 'MMMM yyyy')}} | Nisan 2021 | tr-TR | |
/MM/yyyy') }} | 31/01/2014 | 09:00||
{{ format(MyDate) }} | 31.1.2014 09:00 | tr-TR | |
{{ format(MyDate,'d') }} | 31/01/2014 | ||
{{ format(MyDate,'D') }} | Monday, June 15, 2009 | en-US | |
{{ format(MyDate,'o') }} | 2014-01-31T09:00:00+02:00 |
...
Code Block |
---|
$Xml.SetValue('Test/testdate', new DateTimeOffset()); // testdate will be saved to an XML as "2015-11-12T15:27:16.2568549+02:00" $Xml.SetValue('Test/testdate2', $Xml.Format("{{ format(Test/testdate,'yyyy-MM-dd') }}")); // testdate2 will be saved to an XML as "2015-12-11" // result : 2015-12-11 |
Text Masking
Template system also provides an mask function to filter displayed text on screen. This function can used to filter out personal data like name, credit card, identity number etc. More details can be found at mask function reference.
...
Format Function Options
Data Type | Format Option | Description | Sample Data | Output |
---|---|---|---|---|
String | Print string as automatically detection | <script>alert('hello')</script><div>hello</div> | <div>hello</div> | |
String | Print string as automatically detection | 12.345 | 12.3 | |
String | Print string as automatically detection | 12 | 12 | |
String | Print string as automatically detection | 2022-05-07T00:00:00+03:00 | 07.05.2022 00:00 | |
String | Print string as automatically detection | True / true | ✓ (U+2713) | |
String | Print string as automatically detection | False / false | ✕ (U+2715) | |
String | html | Print string as encoded html text | <script>alert('hello')</script><div>hello</div> | "<script>alert('hello')</script><div>hello</div>" |
String | safe | Print value as safe html with discarding dangerous tags | <script>alert('hello')</script><div>hello</div> | <div>hello</div> |
String | string | Print string without any encoding applied | <script>alert('hello')</script><div>hello</div> | <script>alert('hello')</script><div>hello</div> |
Number | n0 | Print number as integer without any decimal | 12.345 | 12 |
Number | n1 | Print number as decimal with 1 number after dot | 12.345 | 12.3 |
Boolean | Print value as unicode check mark | True / true | ✓ (U+2713) | |
Boolean | Print value as unicode check mark | False / false | ✕ (U+2715) | |
DateTime | Print date value in user's locale preference | 2022-05-07T00:00:00+03:00 | 07.05.2022 00:00 | |
DateTime | o | Print date in ISO format | 2022-05-07T00:00:00+03:00 | 2022-05-07T00:00:00+03:00 |
DateTime | m | Print date in dynamic formatted format | 2022-05-07T00:00:00+03:00 | 2 days ago |
DateTime | dd/MM/yyyy | Print date in specified date format | 2022-05-07T00:00:00+03:00 | 07/05/2022 |
Conditional Formatting
If conditional rendering is needed, the format below can be used:
...