Sightly templating script is designed not to have such logics other than just rendering piece of it. As @edubey mentioned, you can use JS Use API or do all that operations in your Sightly model or sling model class itself and send the actual value which needs to be displayed.