//
// Description
// Perform substitution on the template. We do not really recurse
// downward in the sense that we do not do subsitutions on inferior
// templates. For each inferior template which is a part of this
// template, we insert the current value of their results.
//
// Notes
// Do I want to make this return a reference?
function subst ($handle, $tag, $autoload = true) {
$append = false;
$debug = $this->DEBUGALL || $this->DEBUG['subst'];
$this->LAST = $handle;
if ($debug)
$this->logwrite ("subst (handle=$handle, tag=$tag, autoload=$autoload)");
// For compatibility with FastTemplate, the results need to overwrite
// for an array. This really only seems to be useful in the case of
// something like
// $t->parse ('MAIN', array ('array', 'main'));
// Where the 'main' template has a variable named MAIN which will be
// set on the first pass (i.e., when parasing 'array') and used on the
// second pass (i.e., when parsing 'main').
if (gettype($tag) == 'array') {
foreach (array_values($tag) as $t) {
if ($debug)
$this->logwrite ("subst: calling subst($handle,$t,$autoload)");
$this->subst ($handle, $t, $autoload);
}
return $this->HANDLE[$handle];
}
// Period prefix means append result to pre-existing value.
if (substr($tag,0,1) == '.') {
$append = true;
$tag = substr ($tag, 1);
if ($debug)
$this->logwrite ("subst (handle=$handle, tag=$tag, autoload=$autoload) in append mode");
}
// $this->TEMPLATE[$tag] will only be set if it was explicitly
// declared via define(); i.e., inferior templates will not have an
// entry.
if (isset($this->TEMPLATE[$tag])) {
if (!isset($this->TEMPLATE[$tag]['parsed'])
|| !$this->TEMPLATE[$tag]['parsed'])
$this->parse_internal ($tag);
} else {
&