<?xml version="1.0" encoding="utf-8"?>
<zone{% if entry.target is defined %} target="{{ entry.target }}"{% endif %}>
  <short>{{ short|default(name)|upper  }}</short>
{% if description is defined %}
  <description>{{ description }}</description>
{% endif %}
{% for tag in entry %}
{# Settings which can be used several times #}
{% if tag in ['interface','source','service','port','protocol','icmp-block','forward-port','source-port'] %}
{% for subtag in entry[tag] %}
  <{{ tag }}{% for name,value in subtag.items() %} {{ name }}="{{ value }}"{% endfor %}/>
{% endfor %}
{# Settings which can be used once #}
{% elif tag in ['icmp-block-inversion','masquerade'] and item[tag] == true %}
  <{{ tag }}/>
{% endif %}
{% endfor %}
{# Begin rich rule #}
{% for rule in entry.rule|default([]) %}
  <rule{% if rule.family is defined %} family="{{ rule.family }}"{% endif %}>
{% for tag in rule %}
{% if tag in ['source','destination','service','port','icmp-block','icmp-type','masquerade','forward-port'] %}
    <{{ tag }}{% for name,value in tag.items()|default({}) %} {{ name }}="{{ value }}"{% endfor %}/>
{% elif tag in ['log','audit','accept','drop','mark','reject'] %}
    <{{ tag }}{% for name,value in tag.items() %} {{ name }}="{{ value }}"{% endfor %}>
{% endif %}
{% if tag.limit is defined %}
      <limit value="{{ tag.limit }}"/>
{% endif %}
    </{{ tag }}>
{% endfor %}
  </rule>
{# End rich rule #}
{% endfor %}
</zone>
