This method is deprecated or moved on the latest stable version.
The last existing version (v1_8_7_330) is shown here.
substitute_into(lines, values)
public
Substitute a set of key/value pairs into the given template. Keys with
scalar values have them substituted directly into the page. Those with
array values invoke substitute_array (below), which examples a
block of the template once for each row in the array.
This routine also copes with the IF:key directive, removing chunks
of the template if the corresponding key does not appear in the hash, and
the START: directive, which loops its contents for each value in an array
# File lib/rdoc/template.rb, line 161
def substitute_into(lines, values)
@context.push(values)
skip_to = nil
result = []
while line = lines.read
case line
when /^IF:(\w+)/
lines.read_up_to(/^ENDIF:#$1/) unless @context.lookup($1)
when /^IFNOT:(\w+)/
lines.read_up_to(/^ENDIF:#$1/) if @context.lookup($1)
when /^ENDIF:/
;
when /^START:(\w+)/
tag = $1
body = lines.read_up_to(/^END:#{tag}/)
inner_values = @context.lookup(tag)
raise "unknown tag: #{tag}" unless inner_values
raise "not array: #{tag}" unless inner_values.kind_of?(Array)
inner_values.each do |vals|
result << substitute_into(body.dup, vals)
end
else
result << expand_line(line.dup)
end
end
@context.pop
result.join("\n")
end