X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=template.php;h=5b03754f5febfdee62db00aad6c19d09a6b24e59;hb=73490300ca9dea6fc3c6d3a474ab49796fd58438;hp=36e1ad12a6dda03d7b39bca7f4a4d5e6aa4967ac;hpb=883f464e943d1588c0c4227d7f6e69dedb7b6a21;p=wfpl.git diff --git a/template.php b/template.php index 36e1ad1..5b03754 100644 --- a/template.php +++ b/template.php @@ -62,6 +62,11 @@ class tem { $this->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 +240,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 +290,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 +313,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() {