X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;h=43cceae9aa420938498602d32a01cd8f61b094ab;hb=484e7d7390f43456f0dbee648fa9a4e6854401fa;hp=1187a5445bafac746d79156e4afa2c6aaa54f1c3;hpb=22d5fb7ab7d4ee86bd59e194387dca268bd577a1;p=wfpl.git diff --git a/template.php b/template.php index 1187a54..43cceae 100644 --- a/template.php +++ b/template.php @@ -169,6 +169,23 @@ class tem { function output($templ = false) { print($this->run($templ)); } + + # return the contents of the top-level sub-templates + # + # this does not run the sub-templates, so if you've not called tem_sub() on them, they will be blank. + # + # Return a hash. + # keys: name of top level sub-template. + # values: contents of said sub-template. + function top_subs() { + $ret = array(); + if(isset($this->sub_subs['top_level_subs'])) { + foreach($this->sub_subs['top_level_subs'] as $name) { + $ret[$name] = $this->get($name); + } + } + return $ret; + } } # Below are functions so you can use the above class without allocating or @@ -240,5 +257,9 @@ function template_run($template, &$keyval) { return preg_replace_callback(array('||', '|~([^~]*)~|', '|([^<]*)|', '|

([^<]*)

|'), 'template_filler', $template); } +function tem_top_subs() { + tem_init(); + return $GLOBALS['wfpl_template']->top_subs(); +} ?>