zone "<%= @zone %>" {
    type <%= @zonetype %>;
<% if @zonetype == 'forward' -%>
    forward <%= @forward %>;
<% unless @forwarders.empty? -%>
    forwarders { <%= @forwarders.join('; ') %>; };
<% end -%>
<% end -%>
<% if @manage_file or @manage_file_name -%>
    file "<%= @zonefilename %>";
<% end -%>
<% if @zonetype == 'master' -%>
    update-policy {
            grant rndc-key zonesub ANY;
            <%- @update_policy_rules.sort_by {|k, v| k}.each do |key, key_hash| -%>
            grant <%= key %> <%= key_hash['matchtype'] %> <% if key_hash['tname'] %><%= key_hash['tname'] %> <% end %><% if key_hash['rr'] %><%= key_hash['rr'] %><% end %>;
            <%- end -%>
    };
<% end -%>
<% unless @allow_transfer.empty? -%>
    allow-transfer { <%= @allow_transfer.join('; ') %>; };
<% end -%>
<% unless @allow_query.empty? -%>
    allow-query { <%= @allow_query.join('; ') %>; };
<% end -%>
<% unless @also_notify.empty? -%>
    also-notify { <%= @also_notify.join('; ') %>; };
<% end -%>
<% unless @masters.empty? -%>
    masters { <%= @masters.join('; ') %>; };
<% end -%>
<% if @_dns_notify -%>
    notify <%= @_dns_notify %>;
<% end -%>
};
