New answers tagged

2

You're getting the error because of Twig's operator precedence. Filters take priority over math. So basically Twig was trying change var2 to a percentage first instead of using the results of the math expression first, ie: {{ var1 / (var2 | percentage) }} Generally this behavior is usually what you want but sometimes there's edge cases where it doesn't work ...


1

I got the Craft percentage filter to work by enclosing the calculation in parens, like this: {{ (var1 / var2) | percentage }}


Top 50 recent answers are included