Skip to content

Support for a precision-based round/floor/ceil function #196

@rdmurphy

Description

@rdmurphy

JavaScript has built-in functions for doing rounding calculations via the Math object. But what is missing is a way to supply a precision value to control where the rounding takes place in a number.

Lodash's version makes it possible to pass in a second parameter declaring the precision. Jinja2's filters also include a round() function that accepts a precision value and a flag for which rounding logic to use. And because Jinja2 does it, so does Nunjucks. (This does mean that Nunjucks doesn't technically need this enhancement.)

And while the logic to do this isn't complicated it's maybe just annoying enough to re-find/copy in that this would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions