class Asciidoctor::DocBook45::BlockTableTemplate

def template

def template
  @template ||= @eruby.new <<-EOS
#encoding:UTF-8%><<%= title? ? 'table' : 'informaltable'%>#{id}#{role}#{xreflabel} frame="<%= attr :frame, 'all'%>"
  rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>">
#{title}
<% 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 {|tsec| !rows[tsec].empty? }.each do |tsec| %>
  <t<%= tsec %>>
    <% @rows[tsec].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 tsec == :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<%= tsec %>>
  <% end %>
</tgroup>
<%= title? ? 'table' : 'informaltable'%>>
  EOS
end