Reputation: 21173
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.
Upvotes: 7
Views: 4738
Reputation: 6933
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)
Upvotes: 2
Reputation: 88747
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().
Upvotes: 3