Template Engine language reference > Template Engine utilities > Picture clauses

Picture clauses
The picture clause function $pce.format can be applied to content in a template. A picture clause is a sequence of characters that specify rules for how to parse and format textual data such as dates, times and numbers. When processing the template, the picture clause determines how to transform raw data values into formatted values.
Syntax
$pce.format(<clause>, <input>[, <locale>])
clause
The picture clause to use. See the StoryTeller documentation for information about supported picture clauses.
input
locale
The locale, e.g. en_US. If this argument is not specified, the default locale specified for the Template Engine Process will be used.
The arguments can be specified as strings or as variables.
Locale
A locale must be defined when using the $pce.format function. The locale determines for example how to format date and currency for different languages. You can specify a default locale when you configure the Template Engine Process in Design Center. To use the default locale in the $pce.format function you only have to specify which picture clause to use and the content to apply the picture clause to. If you want to override the default locale, or if it is not specified, you must add a locale as argument to the $pce.format function.
You can use the function $pce.defaultLocale to get the default locale (if specified). For example, if you add this function to your template, the default locale will be displayed in the output.
Template examples
Example 83
Template
#set($input = '12345.6789')
Input number: $input
Clause .9: $pce.format('.9', $input)
Clause .99: $pce.format('.99', $input)
Clause 9.9: $pce.format('9.9', $input)
Clause 9.z: $pce.format('9.z', $input)
Clause z.9: $pce.format('z.9', $input)
Clause zz,zz9.9: $pce.format('zz,zz9.9', $input)
Clause zz,zz9.99: $pce.format('zz,zz9.99', $input)
Clause zz,zz9.9z: $pce.format('zz,zz9.9z', $input)
Clause zz,zz9.99z: $pce.format('zz,zz9.99z', $input)
Output
Input number: 12345.6789
Clause .9: 12345.7
Clause .99: 12345.68
Clause 9.9: 12345.7
Clause 9.z: 12345.7
Clause z.9: 12345.7
Clause zz,zz9.9: 12,345.7
Clause zz,zz9.99: 12,345.68
Clause zz,zz9.9z: 12,345.68
Clause zz,zz9.99z: 12,345.679
 
Example 84
Template
#set($input = '12345')
Input number: $input
Clause .9: $pce.format('.9', $input)
Clause .99: $pce.format('.99', $input)
Clause 9.9: $pce.format('9.9', $input)
Clause 9.z: $pce.format('9.z', $input)
Clause z.9: $pce.format('z.9', $input)
Clause zz,zz9.9: $pce.format('zz,zz9.9', $input)
Clause zz,zz9.99: $pce.format('zz,zz9.99', $input)
Clause zz,zz9.9z: $pce.format('zz,zz9.9z', $input)
Clause zz,zz9.99z: $pce.format('zz,zz9.99z', $input)
Output
Input number: 12345
Clause .9: 12345.0
Clause .99: 12345.00
Clause 9.9: 12345.0
Clause 9.z: 12345
Clause z.9: 12345.0
Clause zz,zz9.9: 12,345.0
Clause zz,zz9.99: 12,345.00
Clause zz,zz9.9z: 12,345.0
Clause zz,zz9.99z: 12,345.00
 
Example 85
Template
#set($clDate='date.full{}') #set($inDate='20131224')
#set($clCurr='num.currency{}') #set($inCurr='3489')
Default locale: $pce.defaultLocale
DateDefaultLocale: $pce.format($clDate, $inDate)
CurrDefaultLocale: $pce.format($clCurr, $inCurr)
DateUSlocale: $pce.format($clDate, $inDate, 'en_US')
CurrUSlocale: $pce.format($clCurr, $inCurr, 'en_US')
Output
Default locale: sv_SE
DateDefaultLocale: Tisdagen den 24:e december 2013
CurrDefaultLocale: 3 489,00 kr
DateUSlocale: Tuesday, December 24, 2013
CurrUSlocale: $3,489.00
 
OpenText StreamServe 5.6.2 Updated: 2018-01-26