class Asciidoctor::DocBook45::DocumentTemplate

Public Instance Methods

docinfo() click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 53
  def docinfo
    "    <% if has_header? && !notitle %>
    <%= template.title_tags(@header.title) %>
    <% end %>
    <% if attr? :revdate %>
    <date><%= attr :revdate %></date>
    <% else %>
    <date><%= attr :docdate %></date>
    <% end %>
    <% if has_header? %>
    <% if attr? :author %>
    <% if (attr :authorcount).to_i < 2 %>
    <author>
      #{tag 'firstname', :firstname}
      #{tag 'othername', :middlename}
      #{tag 'surname', :lastname}
      #{tag 'email', :email}
    </author>
    #{tag 'authorinitials', :authorinitials}
    <% else %>
    <authorgroup>
    <% (1..((attr :authorcount).to_i)).each do |idx| %>
      <author> 
        #{tag 'firstname', :"firstname_\#{idx}", true}
        #{tag 'othername', :"middlename_\#{idx}", true}
        #{tag 'surname', :"lastname_\#{idx}", true}
        #{tag 'email', :"email_\#{idx}", true}
      </author> 
    <% end %>
    </authorgroup>
    <% end %>
    <% end %>
    <% if (attr? :revnumber) || (attr? :revremark) %>
    <revhistory>
      <revision>
        #{tag 'revnumber', :revnumber}
        #{tag 'date', :revdate}
        #{tag 'authorinitials', :authorinitials}
        #{tag 'revremark', :revremark}
      </revision>
    </revhistory>
    <% end %>
<%= docinfo %>
    #{tag 'orgname', :orgname}
    <% end %>
"
  end
template() click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 102
  def template
    @template ||= @eruby.new "<%#encoding:UTF-8%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<% if attr? :toc %><?asciidoc-toc?><% end %>
<% if attr? :numbered %><?asciidoc-numbered?><% end %>
<% if doctype == 'book' %>
<book<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
  <bookinfo>
#{docinfo}
  </bookinfo>
<%= content.chomp %>
</book>
<% else %>
<article<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
  <articleinfo>
#{docinfo}
  </articleinfo>
<%= content.chomp %>
</article>
<% end %>
"
  end
title_tags(str) click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 43
def title_tags(str)
  if str.include?(': ')
    title, _, subtitle = str.rpartition(': ')
    %Q(<title>#{title}</title>
  <subtitle>#{subtitle}</subtitle>)
  else
    %Q(<title>#{str}</title>)
  end
end