6 # An ERb wrapper that allows nesting of one ERb template inside another.
8 # This TemplatePage operates similarly to RDoc 1.x's TemplatePage, but uses
9 # ERb instead of a custom template language.
11 # Converting from a RDoc 1.x template to an RDoc 2.x template is fairly easy.
13 # * %blah% becomes <%= values["blah"] %>
14 # * !INCLUDE! becomes <%= template_include %>
15 # * HREF:aref:name becomes <%= href values["aref"], values["name"] %>
16 # * IF:blah becomes <% if values["blah"] then %>
17 # * IFNOT:blah becomes <% unless values["blah"] then %>
18 # * ENDIF:blah becomes <% end %>
19 # * START:blah becomes <% values["blah"].each do |blah| %>
20 # * END:blah becomes <% end %>
22 # To make nested loops easier to convert, start by converting START statements
25 # <% values["blah"].each do |blah| $stderr.puts blah.keys %>
27 # So you can see what is being used inside which loop.
29 class RDoc::TemplatePage
32 # Create a new TemplatePage that will use +templates+.
34 def initialize(*templates)
35 @templates = templates
39 # Returns "<a href=\"#{ref}\">#{name}</a>"
43 "<a href=\"#{ref}\">#{name}</a>"
50 # Process the template using +values+, writing the result to +io+.
52 def write_html_on(io, values)
56 @templates.reverse_each do |template|
57 template_include = ERB.new(template).result b
60 io.write template_include