def template
@template ||= @eruby.new "<%#encoding:UTF-8%><<%= title? ? 'table' : 'informaltable'%>#{common_attrs_erb} frame="<%= attr :frame, 'all'%>"
rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>">
#{title_tag}
<% if attr? :width %>
<?dbhtml table-width="<%= attr :width %>"?>
<?dbfo table-width="<%= attr :width %>"?>
<?dblatex table-width="<%= attr :width %>"?>
<% end %>
<tgroup cols="<%= attr :colcount %>">
<% @columns.each do |col| %>
<colspec colname="col_<%= col.attr :colnumber %>" colwidth="<%= col.attr((attr? :width) ? :colabswidth : :colpcwidth) %>*"/>
<% end %>
<% [:head, :foot, :body].select {|tblsec| !rows[tblsec].empty? }.each do |tblsec| %>
<t<%= tblsec %>>
<% @rows[tblsec].each do |row| %>
<row>
<% row.each do |cell| %>
<entry#{attribute('align', 'cell.attr :halign')}#{attribute('valign', 'cell.attr :valign')}<%
if cell.colspan %> namest="col_<%= cell.column.attr :colnumber %>" nameend="col_<%= (cell.column.attr :colnumber) + cell.colspan - 1 %>"<%
end %><% if cell.rowspan %> morerows="<%= cell.rowspan - 1 %>"<% end %>><%
if tblsec == :head %><%= cell.text %><%
else %><%
case cell.attr(:style)
when :asciidoc %><%= cell.content %><%
when :verse %><literallayout><%= template.preserve_endlines(cell.text, self) %></literallayout><%
when :literal %><literallayout class="monospaced"><%= template.preserve_endlines(cell.text, self) %></literallayout><%
when :header %><% cell.content.each do |text| %><simpara><emphasis role="strong"><%= text %></emphasis></simpara><% end %><%
else %><% cell.content.each do |text| %><simpara><%= text %></simpara><% end %><%
%><% end %><% end %></entry>
<% end %>
</row>
<% end %>
</t<%= tblsec %>>
<% end %>
</tgroup>
</<%= title? ? 'table' : 'informaltable'%>>
"
end