[pmwiki-devel] FmtTemplateVars function
Patrick R. Michaud
pmichaud at pobox.com
Wed Feb 11 13:27:23 CST 2009
On Wed, Feb 11, 2009 at 04:44:08PM +0000, Hans wrote:
> Tuesday, February 10, 2009, 7:32:12 PM, Patrick wrote:
>
> > We can also update FmtTemplateVars to do things based on PTVs --
> > i.e., {$$:Name} would be an immediate template substitution of
> > the 'Name' PTV for a page.
>
> you mean a straight substitution like with this change,
> adding one line?
>
> foreach(preg_grep('/^[\\w$]/', array_keys($vars)) as $k)
> if (!is_array($vars[$k])) {
> $text = str_replace("{\$\$$k}", $vars[$k], $text);
> $text = str_replace("{\$\$:$k}", $vars[$k], $text);
> }
>
> That would be useful.
No, because that would simply cause {$$:Name} and {$$Name} to
be replaced by the same (pagevar) value. I'm thinking more like:
$text = preg_replace("/\\{\\$(\\$:\\w+)\\}/e",
"PVSE(PageVar(\$pagename, '$1'))");
Pm
More information about the pmwiki-devel
mailing list