{% for name, value in widget.attrs.items %}
  {% if value is not False %} {# exclude value is False #}
    {# if value is exactly `True` then keep the name only #}
    {{ name }} {% if value is not True %}="{{ value|stringformat:'s' }}" {% endif %}
  {% endif %}
{% endfor %}
