{# templates/macros.html #}
{% macro format_bandwidth(bw_value) %}
{% if bw_value is defined %}
{% set bw = bw_value|float %}
{% if bw >= 1000000 %}
{{ (bw / 1000000)|round(2) }} {{ _("Gbps") }}
{% elif bw >= 1000 %}
{{ (bw / 1000)|round(2) }} {{ _("Mbps") }}
{% else %}
{{ bw|round(2) }} {{ _("Kbps") }}
{% endif %}
{% else %}{{ _("0 kbps") }}{% endif %}
{% endmacro %}