macros.html 412 B

12345678910111213
  1. {# templates/macros.html #}
  2. {% macro format_bandwidth(bw_value) %}
  3. {% if bw_value is defined %}
  4. {% set bw = bw_value|float %}
  5. {% if bw >= 1000000 %}
  6. {{ (bw / 1000000)|round(2) }} {{ _("Gbps") }}
  7. {% elif bw >= 1000 %}
  8. {{ (bw / 1000)|round(2) }} {{ _("Mbps") }}
  9. {% else %}
  10. {{ bw|round(2) }} {{ _("Kbps") }}
  11. {% endif %}
  12. {% else %}{{ _("0 kbps") }}{% endif %}
  13. {% endmacro %}