Formatting currencies in Sightly | Community
Skip to main content
Level 2
October 16, 2015
Solved

Formatting currencies in Sightly

  • October 16, 2015
  • 1 reply
  • 1835 views

Hi,

We need to display currencies that are locale sensitive in Sightly. Using JSP and JSTL this is fairly easy :

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="balance" value="120000.2309" /> <fmt:formatNumber value="${balance}" type="currency"/>

And we would get something like £120,000.23.

How do we do the same in sightly ? We really don't want our models to do the formatting, as this is really a view level concern.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

for this you can use the use-api (data-sly-use) and create a Javascript/Java object for this, and this is then reusable for your components.

<div data-sly-use.format="{ 'yourpackage.YourFormatClass' @ value = value, format = format}">

${format.formattedValue}

</div>

1 reply

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

for this you can use the use-api (data-sly-use) and create a Javascript/Java object for this, and this is then reusable for your components.

<div data-sly-use.format="{ 'yourpackage.YourFormatClass' @ value = value, format = format}">

${format.formattedValue}

</div>