class BaseTemplate def initialize end def self.inherited(klass) @template_classes ||= [] @template_classes << klass end def self.template_classes @template_classes end # We're ignoring locals for now. Shut up. def render(obj = Object.new, locals = {}) output = template.result(obj.instance_eval {binding}) end def template raise "You chilluns need to make your own template" end end class DocumentTemplate < BaseTemplate def template @template ||= ::ERB.new <<-EOF
<%= content %>
EOF end end class SectionTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<% if !anchor.nil? %> <% end %> id='<%= section_id %>'><%= name %>> <% if level == 1 %>
<%= content %>
<% else %> <%= content %> <% end %>
EOF end end class SectionAnchorTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF EOF end end class SectionDlistTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<% content.each do |dt, dd| %>
<%= dt %>
<% unless dd.nil? || dd.empty? %>
<%= dd %>
<% end %> <% end %>
EOF end end class SectionListingTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<%= content %>
EOF end end class SectionLiteralTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<%= content %>
EOF end end class SectionNoteTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<% if !title.nil? %>
<%= title %>
<% end %> <%= content %>
EOF end end class SectionParagraphTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
<% if !title.nil? %>
<%= title %>
<% end %>

<%= content %>

EOF end end class SectionSidebarTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF

<%= content %>

EOF end end class SectionUlistTemplate < BaseTemplate def template @template ||= ERB.new <<-EOF
EOF end end =begin ../gitscm-next/templates/section_colist.html.erb
    <% content.each do |li| %>
  1. <%= li %>

  2. <% end %>
../gitscm-next/templates/section_example.html.erb
<%= content %>
../gitscm-next/templates/section_oblock.html.erb
<%= content %>
../gitscm-next/templates/section_olist.html.erb
    <% content.each do |li| %>
  1. <%= li %>

  2. <% end %>
../gitscm-next/templates/section_quote.html.erb
<%= content %>
../gitscm-next/templates/section_verse.html.erb
<%= content %>
=end