$ORIGIN <%= @name -%>.
$TTL <%= @ttl -%>

@   SOA   <%= @nameservers[0] -%>.  hostmaster.<%= @name -%>. (
          serialnumber ; Serial Number
          <%= @refresh -%>   ; Refresh
          <%= @retry -%>    ; Retry
          <%= @expire -%>  ; Expire
          <%= @negresp -%>     ; Neg response TTL
          )
<% @nameservers.each do |n| -%>
      NS   <%=  n %>.
<% end %>
<% @merged_zone.each do |key,value| -%>
<% require 'resolv' -%>
<% if value =~ Resolv::IPv4::Regex -%>
<%= key.gsub("\.#{@name}", '') -%>    IN    A   <%= value %>
<% elsif (key =~ /SUBDOM\d+?_/) -%>
<% keySUB = key.split('_')[1] -%>
<%= keySUB.gsub("\.#{@name}", '') -%> IN NS <%= value %>
<% elsif (key =~ /TXT\d+?_/) -%>
<% keySUB = key.split('_')[1..-1] -%>
<%= keySUB.gsub("\.#{@name}", '') -%> TXT <%= value %>
<% else -%>
<%= key.gsub("\.#{@name}", '') -%>    IN    CNAME   <%= value %>
<% end -%>
<% end -%>

$ORIGIN <%= @name -%>.
$TTL <%= @ttl -%>

@   SOA   <%= @nameservers[0] -%>.  hostmaster.<%= @name -%>. (
          serialnumber ; Serial Number
          <%= @refresh -%>   ; Refresh
          <%= @retry -%>    ; Retry
          <%= @expire -%>  ; Expire
          <%= @negresp -%>     ; Neg response TTL
          )
<% @nameservers.each do |n| -%>
      NS   <%=  n %>.
<% end %>
<% @merged_zone.each do |key,value| -%>
<% require 'resolv' -%>
<% if value =~ Resolv::IPv4::Regex -%>
<%= key.gsub("\.#{@name}", '') -%>    IN    A   <%= value %>
<% elsif (key =~ /SUBDOM\d+?_/) -%>
<% keySUB = key.split('_')[1] -%>
<%= keySUB.gsub("\.#{@name}", '') -%> IN NS <%= value %>
<% elsif (key =~ /TXT\d+?_/) -%>
<% keySUB = key.split('_')[1..-1].join("_")-%>
<%= keySUB.gsub("\.#{@name}", '') -%> TXT <%= value %>
<% else -%>
<%= key.gsub("\.#{@name}", '') -%>    IN    CNAME   <%= value %>
<% end -%>
<% end -%>

Support underscores in txt record name
Support underscores in txt record name
