[PERCEPS] Error handling {if first} and {if last}

Noel Welsh Noel@acis.uk.com
Fri, 17 Sep 1999 10:10:34 +0100


Hi perceps users,

I'm getting very near to finishing some C to HTML templates, but I've
run into error processing if's within foreach loops.

I have loops like

{foreach typedef sort "$a cmp $b;"}
	{if first}
		<h3 class=toc-section-title><a
name="types">Types</a></h3>
		<ul>
	{endif}
	<li>
		<p><span class=toc-entry><a
href="#type-{name}"><strong>{name}</strong></a></span><br>
		<span class=toc-summary><em>{brief}</em></span></p>
	</li>
	{if last}
		</ul>
	{endif}
{next}

to generate the table of contents. The first or last directive is
skipped, apparently at random, leading to lists within lists that crawl
towards the right of the screen. It's probably my stupidity, but I've
been staring at it too long to see what's wrong. Either that or it's
gremlins. Or there is a bug in Perceps. Attached below is the full
template. I plan to release these soon, in case anyone is interested.

I'm also curious about the Perceps replacement under development. What's
this projects hackability? As a side-note, it seems that a real parser
would be a good thing. Regexp only go so far (which admittedly is quite
far), but they inevitably reach limitation as seen with Emacs cc-mode. 

Thanks in advance,
Noel

---

{keephtml}

Description of {module}





Documentation

{module}

{foreach macro} {if name /MODULE/}

{brief}

{detail}

{endif} {next}
{foreach macro} {if first}

Macros

{endif} {next} {foreach typedef sort "$a cmp $b;"} {if first}

Types

{endif} {next} {foreach global sort "$a cmp $b;"} {if first}

Variables

{endif} {next} {foreach func sort "$a cmp $b;"} {if first}

Functions

{endif} {next}

Macros Detail

{foreach macro sort "$a cmp $b;"} {if public}

public {name}

{brief}

{detail}


{endif} {next} {foreach macro sort "$a cmp $b;"} {if private}

private {name}

{brief}

{detail}


{endif} {next}

Types Detail

{foreach typedef sort "$a cmp $b;"} {if public}

public {name}

{brief}

{detail}


{endif} {next} {foreach typedef sort "$a cmp $b;"} {if private}

private {name}

{brief}

{detail}


{endif} {next}

Variables Detail

{foreach global sort "$a cmp $b;"} {if public}

public {name}

{brief}

{detail}


{endif} {next} {foreach global sort "$a cmp $b;"} {if private}

private {name}

{brief}

{detail}


{endif} {next}

Functions Detail

{foreach func sort "$a cmp $b;"} {if public}

public {type} {name}({args})

{brief}

{if return}

Return Value:

{return}

{endif} {if see}

See Also:

{see}

{endif}

{detail}


{endif} {next} {foreach func sort "$a cmp $b;"} {if private}

private {type} {name}({args})

{brief}

{if return}

Return Value:

{return}

{endif} {if see}

See Also:

{see}

{endif}

{detail}


{endif} {next}