[pmwiki-users] RFC: hypothetical PageVariableExtensions recipe
Patrick R. Michaud
pmichaud at pobox.com
Wed Apr 12 11:14:02 CDT 2006
On Wed, Apr 12, 2006 at 05:28:49PM +0200, Dominique Faure wrote:
> (:initvars myvariable='my value' answer=42:)
>
> This markup defines two variables. Despite their values are provided
> with the regular syntax: {$myvariable} or {$answer}, they couldn't be
> reached directly from other pages as in {Group.Page$answer} (BTW, this
> is the 1st and I fear unavoidable issue).
It can be made to be reachable from other pages; the variables
just have to be turned into page attributes. This isn't that
difficult -- PmWiki already does this for the (:title:), (:keywords:),
and (:description:) pages, and in the Cookbook it does it for
the "Summary:", "Version:", and "Votes:" properties. (I.e., someone
can write {Cookbook.RandomQuote$Summary} to get the summary of the
Cookbook.RandomQuote page.)
> The second issue is that I couldn't (for now) mix variables
> and conditions:
> (:initvars var='something':)
> (:if false:)
> (:initvars var='nothing':)
> (:if:)
> var's value is {$var}
> renders as:
> var's value is nothing
> which is not what is expected.
...welcome to PmWiki's chicken-and-egg problem. The question is
one of ordering -- in this case, the ordering between the
(:initvars:) markup and the (:if:) markup.
If we say that (:initvars:) is to be processed before (:if:),
then one cannot use conditional markups to control (:initvars:).
If we say that (:initvars:) is to be processed after (:if:),
then we cannot use page variables set by (:initvars:) as part
of an (:if:) conditional -- i.e., we cannot do
(:initvars super=hello:)
(:if equal {$super} "hello":)
Alas, we'll never see this.
(:if:)
As I've mentioned a couple of times before -- I don't yet have a
good answer to these problems except by drastically re-working
PmWiki's formatting engine (likely breaking a lot of recipes
and sites in the process).
However, I do have some mediocre answers to the problem, such as
using different directives depending on when we want the variable
to be initialized, but I fear that approach will simply end up
being too confusing to be practical.
Adding this sort of capability is something I definitely want to
do for PmWiki, but I'm waiting for a good answer.
What order are you planning to use for (:initvars:), {$...},
and (:if:) markups?
Pm
More information about the pmwiki-users
mailing list