Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueljl
Copy link

No description provided.

@@ -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));
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcode format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants