Open
Description
🐞 Problem
The numberFormat
Handlebars helper's Javadoc suggests that locale
can be passed as a named parameter:
/**
* Usage:
*
* <pre>
* {{numberFormat number ["format"] [locale=default]}}
* </pre>
*/
This locale=default
syntax strongly implies that named parameters like locale="fr"
should be supported.
However, in practice, only positional parameters are supported:
🔍 Root Cause
In the implementation, only options.param(...)
is used:
String format = options.param(0);
String localeStr = options.param(1, Locale.getDefault().toString());
Named parameters such as options.hash("locale")
are never checked.
✅ Suggested Improvement
Adopt the same pattern used in the dateFormat
helper, which supports both positional and named parameters for format
and locale
.
Suggested change:
String format = options.param(0, options.hash("format"));
String localeStr = options.param(1, options.hash("locale", Locale.getDefault().toString()))
Locale locale = LocaleUtils.toLocale(localeStr);
This would enable:
🔄 Alternatives
If named parameters are not intended to be supported, the Javadoc should be clarified to remove the implication of named usage.
Metadata
Metadata
Assignees
Labels
No labels