Solved! Go to Solution.
Views
Replies
Total Likes
@vinuu123 Use HTL Number format [1], documentation says:
The formatting pattern supports both a positive and negative pattern, separated by semicolon. Each sub-pattern can have a prefix, a numeric part and a suffix. The negative sub-pattern can only change the prefix or/and suffix. The following characters are supported, at minimum:
0
- digit, shows as 0 if absent#
- digit, does not show if absent.
- decimal separator-
- minus sign,
- grouping separatorE
- separator between mantissa and exponent;
- sub-pattern boundary%
- multiply by 100 and show as percentageCharacters can be escaped in prefix or suffix using single quotes. Single quotes are escaped as two in a row.
Examples:
${'#,###.00' @ format=1000} ${'#.###;-#.###' @ format=obj.number} ${'#.00;(#.00)' @ format=obj.number} ${'#.000E00' @ format=obj.number} ${'#%' @ format=obj.number} ${ 'curr #,###.##' @ format=1000.14, locale='de_CH', i18n}
will generate the following output if obj.number
evaluates to -3.14
:
1,000.00 -3.14 (3.14) -.314E01 -314% CHF 1'000.14 <!--/* assuming the formatter 'curr #,###.##' will be translated to 'CHF #,###.##' for the 'de_CH' locale by i18n */-->
[1] https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md
@vinuu123 Use HTL Number format [1], documentation says:
The formatting pattern supports both a positive and negative pattern, separated by semicolon. Each sub-pattern can have a prefix, a numeric part and a suffix. The negative sub-pattern can only change the prefix or/and suffix. The following characters are supported, at minimum:
0
- digit, shows as 0 if absent#
- digit, does not show if absent.
- decimal separator-
- minus sign,
- grouping separatorE
- separator between mantissa and exponent;
- sub-pattern boundary%
- multiply by 100 and show as percentageCharacters can be escaped in prefix or suffix using single quotes. Single quotes are escaped as two in a row.
Examples:
${'#,###.00' @ format=1000} ${'#.###;-#.###' @ format=obj.number} ${'#.00;(#.00)' @ format=obj.number} ${'#.000E00' @ format=obj.number} ${'#%' @ format=obj.number} ${ 'curr #,###.##' @ format=1000.14, locale='de_CH', i18n}
will generate the following output if obj.number
evaluates to -3.14
:
1,000.00 -3.14 (3.14) -.314E01 -314% CHF 1'000.14 <!--/* assuming the formatter 'curr #,###.##' will be translated to 'CHF #,###.##' for the 'de_CH' locale by i18n */-->
[1] https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md
Hi @vinuu123 ,
Arithmetic Operation is not possible in Sightly, You have to handle this from the backend using Java or JavaScript API.
As Suggested by @Mohit_KBansal , You can use a format pattern to show the percentage and fetching value from the backend.
Please refer to the below useful links:
https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md#1223-numbers
Hope this could help you !!!
Regards
Shiv
Views
Likes
Replies