Code: Select all
(define (<page> %w)
(replace "`(.+?)`" %w (string (eval-string $1)) 516)
(if (> $0 0) (<page> %w) %w))
...
(let (isfred true val "fred")
(print [text]Content-type: text/html
<html>
<body>
<p>`(if test
"Hello `val`!"
"You are not `val`!")`</p>
</body>
</html>[/text]))
1. Lutz was right about using 512 in replace when nesting. Notice `val` nested within the `(if ...)`
2. I added 4 because I needed to match across newlines.
3. I didn't see a post-test loop for newlisp in reference manual. I was fooled by (until ) until I noticed that it meant (while (not ... Still a pre-test loop. The recursive version of (<page> %w) would be a one liner using something like
Code: Select all
(define (<page> %w)
(repeat (> $0 0) (replace "`(.+?)`" %w (string (eval-string $1)) 516)))
What do you think Lutz?
Eddie