A formatter allows to format the evaluation of an expression. ZPT-JS includes some formatters:
format: lowerCase 'Test'evaluates as 'test'format: upperCase 'Test'evaluates as 'TEST'format: fix 1.371 2evaluates as '1.37'format: fix (/: 1 3) 2evaluates as '0.33'
You can register other formatters of your own:
context.registerFormatter(
'myCustomFormatter',
function( value ){
return "$" + value;
}
);
After registering it you will be able to use it as usual:
format: myCustomFormatter aNumber
It is possible to run custom formatters without registering them. They must be functions defined in the dictionary:
format: customFormatter aNumberformats aNumber using a function in the dictionary calledcustomFormatterformat: customFormatterName aNumberformats aNumber using a function in the dictionary called as the value of thecustomFormatterNamevariable