from decimal import Decimal

def register(app):
    @app.template_filter("currency")
    def currency_filter(value, code="GBP"):
        if value is None:
            return ""
        # ensure decimal-ish
        if isinstance(value, float):
            value = Decimal(str(value))
        symbol = "£" if code == "GBP" else code
        return f"{symbol}{value:.2f}"
