Simple question: Can I do the equivalent of Math.ceil and Math.floor in a Velocity template? From what I could find I would have to use MathTool, but that doesn't seem to have what I want.
I'd say you could work with MathTool.roundToInt()
and adding/subtracting 1, but it should also be possible to provide an object with your methods that might provide what you need.
Also have a look at Velocity Tools 2.0 whose MathTool has methods floor() and ceil().
I recommend the Tools 2.0 MathTool for greatest type flexibility, but Velocity Engine's 1.6+ support static methods by putting the class itself into the context. So the quick and easy solution is:
context.put("Math", Math.class);
$Math.ceil($foo) $Math.floor($bar)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With