I read here on SO that Go’s fmt command (used by Hugo’s printf) doesn’t support thousand separators. Would it perhaps be possible to add that to Hugo?
We can already format dates, and I think it will be valuable if we can format numbers too. For example, instead of printing 2354098 formatting it to 2,354,098. That latter format is much easier to read.
the pull request for the numFormat template function is still open. This means it hasn’t been merged in the codebase of Hugo so far. Therefore, you can’t call the function and Hugo 0.16 raises an error.
It looks like the template function was associated with the wrong pull request by accident. We should fix the release notes. This should the correct one:
What’s the status on this feature request? Still worthwhile or not?
As a user I’d still like to use such a feature, but see that from a development standpoint @moorereason’s pull request is still pending. Would be happy to help, but unsure what to do since it seems to be in limbo land now.
Okay, this is ugly, and likely quite slow, but if you have a small number of positive integers you’d like to add commas to, it works. It could easily be extended to handle floating-point numbers with split, but I’ll leave that for someone more motivated.
Also, the search engine for the old docs site won’t find it unless you already know its name, and it doesn’t look like it’s in the new docs site yet. The forum search just turned up this thread, of course.
Oh, well, it was an interesting experiment in working around the limitations in template functionality. Almost as much fun as building a self-contained “jump to random content page” button in my navbar (modern browsers handle huge Javascript arrays surprisingly well…).