-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
customSeparator for price purpose #3
base: master
Are you sure you want to change the base?
Conversation
@@ -43,11 +47,20 @@ public Handlebars handlebars(TemplateLoader templateLoader, TemplateCache templa | |||
Handlebars handlebars = new Handlebars() | |||
.with(templateLoader) | |||
.with(templateCache); | |||
handlebars.registerHelper("customSeparator", (context, options) -> customSeparator((Double) context, options)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not all user need this function
StringHelpers.register(handlebars); | ||
|
||
return handlebars; | ||
} | ||
|
||
public String customSeparator(Double data, Options options) { | ||
String separator = (String) options.hash.getOrDefault("separator", "."); | ||
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create new DecimalFormatSymbols every time customSeparator method invoked?
String separator = (String) options.hash.getOrDefault("separator", "."); | ||
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); | ||
decimalFormatSymbols.setGroupingSeparator(separator.charAt(0)); | ||
DecimalFormat decimalFormat = new DecimalFormat("###,###", decimalFormatSymbols); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcode format?
No description provided.