In Files

  • rdoc/template.rb



Class/Module Index [+]



An ERb wrapper that allows nesting of one ERb template inside another.

This TemplatePage operates similarly to RDoc 1.x’s TemplatePage, but uses ERb instead of a custom template language.

Converting from a RDoc 1.x template to an RDoc 2.x template is fairly easy.

  • %blah% becomes <%= values %>

  • !INCLUDE! becomes <%= template_include %>

  • HREF:aref:name becomes <%= href values, values %>

  • IF:blah becomes <% if values then %>

  • IFNOT:blah becomes <% unless values then %>

  • ENDIF:blah becomes <% end %>

  • START:blah becomes <% values.each do |blah| %>

  • END:blah becomes <% end %>

To make nested loops easier to convert, start by converting START statements to:

<% values["blah"].each do |blah| $stderr.puts blah.keys %>

So you can see what is being used inside which loop.

Public Class Methods

new(*templates) click to toggle source

Create a new TemplatePage that will use templates.

               # File rdoc/template.rb, line 34
def initialize(*templates)
  @templates = templates

Public Instance Methods

href(ref, name) click to toggle source

Returns “<a href="#{ref}">#{name}</a>”

               # File rdoc/template.rb, line 41
def href(ref, name)
  if ref then
    "<a href=\"#{ref}\">#{name}</a>"
write_html_on(io, values) click to toggle source

Process the template using values, writing the result to io.

               # File rdoc/template.rb, line 52
def write_html_on(io, values)
  b = binding
  template_include = ""

  @templates.reverse_each do |template|
    template_include = b

  io.write template_include

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit