class Asciidoctor::BaseTemplate

this same issue.
prevent quote processing. This requirement seems hackish, but AsciiDoc has
NOTE we must use double quotes for attribute values in the HTML/XML output to
backend templates. Concrete subclasses must implement the template method.
An abstract base class that provides methods for definining and rendering the

def self.inherited(klass)

def self.inherited(klass)
  @template_classes ||= []
  @template_classes << klass
end

def self.template_classes

def self.template_classes
  @template_classes
end

def attribute(name, key)

create template matter to insert an attribute if the variable has a value
def attribute(name, key)
  type = key.is_a?(Symbol) ? :attr : :var
  if type == :attr
    # example: <% if attr? 'foo' %> bar="<%= attr 'foo' %>"<% end %>
    %(<% if attr? '#{key}' %> #{name}="<%= attr '#{key}' %>"<% end %>)
  else
    # example: <% if foo %> bar="<%= foo %>"<% end %>
    %(<% if #{key} %> #{name}="<%= #{key} %>"<% end %>)
  end
end

def attrvalue(key, sibling = true)

create template matter to insert a style class if the variable has a value
def attrvalue(key, sibling = true)
  delimiter = sibling ? ' ' : ''
  # example: <% if attr? 'foo' %><%= attr 'foo' %><% end %>
  %(<% if attr? '#{key}' %>#{delimiter}<%= attr '#{key}' %><% end %>)
end

def common_attrs(id, role, reftext)

def common_attrs(id, role, reftext)
  %(#{id && " id=\"#{id}\""}#{role && " role=\"#{role}\""}#{reftext && " xreflabel=\"#{reftext}\""})
end

def common_attrs_erb

def common_attrs_erb
  %q{<%= template.common_attrs(@id, (attr 'role'), (attr 'reftext')) %>}
end

def compact(str)

converted to an endline character.
returns the text with blank lines removed and HTML line feed entities

text - the String to process

every HTML line feed entity found with an endline character.
Public: Compact blank lines in the provided text. This method also restores
def compact(str)
  str.gsub(BLANK_LINES_PATTERN, '').gsub(LINE_FEED_ENTITY, "\n")
end

def id

create template matter to insert an id if one is specified for the block
def id
  attribute('id', '@id')
end

def initialize(view, eruby)

def initialize(view, eruby)
  @view = view
  @eruby = eruby
end

def preserve_endlines(str, node)

node - the concrete instance of Asciidoctor::AbstractNode being rendered
text - the String to process

replacement. Otherwise, return the text unprocessed.
If the compact flag on the document's renderer is true, perform the

Public: Preserve endlines by replacing them with the HTML line feed entity.
def preserve_endlines(str, node)
  node.renderer.compact ? str.gsub("\n", LINE_FEED_ENTITY) : str
end

def render(node = Object.new, locals = {})

locals - A Hash of additional variables. Not currently in use.
node - The concrete instance of AsciiDoctor::AbstractNode to render

the rendered output is returned unprocessed.
document or embedded, then blank lines in the output are compacted. Otherwise,
If the compact flag on the document's renderer is true and the view context is

accessible to the template data via the local variable named 'template'.
supplied concrete instance of Asciidoctor::AbstractNode. This instance is
template data and then evaluates that template in the context of the
This method invokes the template method on this instance to retrieve the

the supplied concrete instance of Asciidoctor::AbstractNode.
Public: Render this template in the execution context of
def render(node = Object.new, locals = {})
  tmpl = template
  case tmpl
  when :invoke_result
    return result(node)
  when :content
    result = node.content
  else
    result = tmpl.result(node.get_binding(self))
  end
  if (@view == 'document' || @view == 'embedded') &&
      node.renderer.compact && !node.document.nested?
    compact result
  else
    result
  end
end

def role_class

create template matter to insert a style class from the role attribute if specified
def role_class
  attrvalue(:role)
end

def style_class(sibling = true)

create template matter to insert a style class from the style attribute if specified
def style_class(sibling = true)
  attrvalue(:style, sibling)
end

def tag(name, key, dynamic = false)

def tag(name, key, dynamic = false)
  type = key.is_a?(Symbol) ? :attr : :var
  key = key.to_s
  if type == :attr
    key_str = dynamic ? %("#{key}") : "'#{key}'"
    # example: <% if attr? 'foo' %><bar><%= attr 'foo' %></bar><% end %>
    %(<% if attr? #{key_str} %><#{name}><%= attr #{key_str} %></#{name}><% end %>)
  else
    # example: <% unless foo.to_s.empty? %><bar><%= foo %></bar><% end %>
    %(<% unless #{key}.to_s.empty? %><#{name}><%= #{key} %></#{name}><% end %>)
  end
end

def template

def template
  raise "You chilluns need to make your own template"
end

def title_div(opts = {})

def title_div(opts = {})
  %(<% if title? %><div class="title">#{opts.has_key?(:caption) ? '<%= @caption %>' : ''}<%= title %></div><% end %>)
end

def title_tag(optional = true)

def title_tag(optional = true)
  if optional
    %q{<%= title? ? "<title>#{title}</title>" : '' %>}
  else
    %q{<title><%= title %></title>}
  end
end