<%! def column_width(column, table): return max(map(lambda row: len(row[column]), table)) if table else 0 %>\ $TTL 600 @ IN SOA ${hostname}. admin.${hostname}. ( 2021070821 ;Serial 3600 ;Refresh 200 ;Retry 1209600 ;Expire 900 ;Negative response caching TTL ) % for record in sorted(records, key=lambda r: (r['name'], r['type'], r['value'])): ${(record['name'] or '@').ljust(column_width('name', records))} \ IN \ ${record['type'].ljust(column_width('type', records))} \ % if record['type'] == 'TXT': (${' '.join('"'+record['value'][i:i+255]+'"' for i in range(0, len(record['value']), 255))}) % else: ${record['value']} % endif % endfor