{% set html = form_generator %}

{% macro widget(field) %}
  {%- set macro = {'input': input}[field.properties.widget] -%}
  {{- macro(field) -}}
{% endmacro %}

{% macro input(field) %}
  {%- do html.begin(auto_domid=true, auto_for=true) %}
<fieldset>
  {{ html.label(field, contents=field.label) }}
  {{ html.input(field, type=field.properties.type) }}
</fieldset>
  {%- do html.end() %}
{% endmacro %}
