class Asciidoctor::DocBook45::SectionTemplate

def section(sec)

def section(sec)
  if sec.special
    tag = sec.level <= 1 ? sec.sectname : 'section'
  else
    tag = sec.document.doctype == 'book' && sec.level <= 1 ? 'chapter' : 'section'
  end
  %(<#{tag}#{common_attrs(sec.id, (sec.attr 'role'), (sec.attr 'reftext'))}>
#{sec.title? ? "<title>#{sec.title}</title>" : nil}
#{sec.content}
#{tag}>)
end

def template

def template
  # hot piece of code, optimized for speed
  @template ||= @eruby.new <<-EOF
#encoding:UTF-8%><%= template.section(self) %>
  EOF
end