def template
@template ||= @eruby.new "<%#encoding:UTF-8%><table\#{id} class=\"tableblock frame-<%= attr :frame, 'all' %> grid-<%= attr :grid, 'all'%>\#{role_class}\" style=\"<%\nif !(attr? 'autowidth-option') %>width:<%= attr :tablepcwidth %>%; <% end %><%\nif attr? :float %>float: <%= attr :float %>; <% end %>\"><%\nif title? %>\n<caption class=\"title\"><% unless @caption.nil? %><%= @caption %><% end %><%= title %></caption><%\nend\nif (attr :rowcount) >= 0 %>\n<colgroup><%\nif attr? 'autowidth-option'\n@columns.each do %>\n<col><%\nend\nelse\n@columns.each do |col| %>\n<col style=\"width:<%= col.attr :colpcwidth %>%;\"><%\nend\nend %>\n</colgroup><%\n[:head, :foot, :body].select {|tsec| !@rows[tsec].empty? }.each do |tsec| %>\n<t<%= tsec %>><%\n@rows[tsec].each do |row| %>\n<tr><%\nrow.each do |cell| %>\n<<%= tsec == :head ? 'th' : 'td' %> class=\"tableblock halign-<%= cell.attr :halign %> valign-<%= cell.attr :valign %>\"\#{attribute('colspan', 'cell.colspan')}\#{attribute('rowspan', 'cell.rowspan')}<%\ncell_content = ''\nif tsec == :head\ncell_content = cell.text\nelse\ncase (cell.attr 'style', nil, false)\nwhen :asciidoc\ncell_content = %(<div>\\\#{cell.content}</div>)\nwhen :verse\ncell_content = %(<div class=\"verse\">\\\#{template.preserve_endlines(cell.text, self)}</div>)\nwhen :literal\ncell_content = %(<div class=\"literal monospaced\"><pre>\\\#{template.preserve_endlines(cell.text, self)}</pre></div>)\nwhen :header\ncell.content.each do |text|\ncell_content = %(\\\#{cell_content}<p class=\"tableblock header\">\\\#{text}</p>)\nend\nelse\ncell.content.each do |text|\ncell_content = %(\\\#{cell_content}<p class=\"tableblock\">\\\#{text}</p>)\nend\nend\nend %><%= (@document.attr? 'cellbgcolor') ? %( style=\"background-color:\\\#{@document.attr 'cellbgcolor'};\") : nil\n%>><%= cell_content %></<%= tsec == :head ? 'th' : 'td' %>><%\nend %>\n</tr><%\nend %>\n</t<%= tsec %>><%\nend\nend %>\n</table>\n"
end