[Pmwiki-users] About [:fi:] (Was: can i get a "live" sidebar?)
Patrick R. Michaud
pmichaud
Sat Oct 16 05:34:22 CDT 2004
On Sat, Oct 16, 2004 at 11:35:36AM +0200, chr at home.se wrote:
> On Fri, 15 Oct 2004, Patrick R. Michaud wrote:
>
> > The [:if ...:] syntax allows portions of the markup text
> > to be conditionally processed (up to the next [:if:]) ...
>
> So a clause statement is not terminated by and end-of-line, but only by
> the next [:if...:] (or end-of-page)?
Right.
> That looks really unintuitive to me... for the example above, why not use
> a syntax like this instead:
> [:if group PmWiki:] Do this in PmWiki group
> [:elseif group Main:] Do something else for Main
> [:if:] This happens in all groups
Because I didn't want to deal with [:else:] and [:elseif:] -- that
requires that I keep track of the status of the previous condition,
or start doing even larger searches/replacements. I'm not trying to
implement a whole programming language--just a simple mechanism to
conditionally include/exclude text. Allowing if/elseif/else/endif
also vaguely implies that [:if:]'s can nest, which isn't true.
Doing an if/elseif/else/endif w/o nesting is probably possible, but
I'll leave that to a Cookbook author for the time being--PmWikiPhilosophy
#3 applies here.
> And I think it'd also be more readable if something like '[:endif:]' could
> be defined as a macro for '[:if:]'.
You can use [:ifend:] (analogous to [:tableend:]). But it'd be no problem
to support [:endif:] as well, and they work exactly the same.
> However, if nested if-statements aren't allowed, I think we will quickly
> run into problems with something like this:
> [:if group PmWiki:][:include Main.SideBarPmWiki:][:endif:]
> when 'Main.SideParPmWiki' contains if-statements. Or am I missing
> something here?
[:if:]'s are processed entire before [:include:]. Thus in the above,
the [:if group PmWiki:]...[:ifend:] gets completely processed before
the [:include:] is processed, thus the result of the outer [:if:] is either
the include itself if we're in the PmWiki group or a null string if we're not.
Then, if Main.SideBarPmWiki contains any if-statements, those get processed
after the include takes place and the outer if is already gone--i.e.,
there's not any interaction between the outer and included ifs.
(Boy that looks confusing to describe, but I think it actually does
what one would hope it would do.)
Pm
More information about the pmwiki-users
mailing list