X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;h=1c775131981ef81b2e1593e31cbd0a95d20c11c4;hb=85176c05d844a9b3c693e3436d358cc1bf30b1eb;hp=36e1ad12a6dda03d7b39bca7f4a4d5e6aa4967ac;hpb=883f464e943d1588c0c4227d7f6e69dedb7b6a21;p=wfpl.git diff --git a/template.php b/template.php index 36e1ad1..1c77513 100644 --- a/template.php +++ b/template.php @@ -1,23 +1,5 @@ keyval[$key] .= $value; } + # like set() but prepends + function prepend($key, $value) { + $this->keyval[$key] = $value . $this->keyval[$key]; + } + # clear a value. Functionally equivalent to set($key, '') but cleaner and more efficient function clear($key) { unset($this->keyval[$key]); @@ -235,6 +222,11 @@ function tem_append($key, $value) { $GLOBALS['wfpl_template']->append($key, $value); } +function tem_prepend($key, $value) { + tem_init(); + $GLOBALS['wfpl_template']->prepend($key, $value); +} + function tem_set($key, $value) { tem_init(); $GLOBALS['wfpl_template']->set($key, $value); @@ -280,7 +272,8 @@ function tem_output($filename = false) { # this is used in template_run() and should be of no other use function template_filler($matches) { - list($tag, $enc) = explode('.', $matches[1], 2); + $match = array_pop($matches); + list($tag, $enc) = explode('.', $match, 2); $value = $GLOBALS['wfpl_template_keyval'][$tag]; if($enc) { $encs = explode('.', $enc); @@ -302,7 +295,7 @@ function template_filler($matches) { # returns the result. function template_run($template, &$keyval) { $GLOBALS['wfpl_template_keyval'] =& $keyval; - return preg_replace_callback(array('||', '|~([^~]*)~|', '|([^<]*)|', '|

([^<]*)

|'), 'template_filler', $template); + return preg_replace_callback('`|~([^~]*)~|([^<]*)|

([^<]*)

`', 'template_filler', $template); } function tem_top_sub_names() {