Tuesday, April 03

Blog

More Iffing About

I've made some FizzBuzz-related enhancements to the new conditional tags.  TTLWAIN* is sufficiently lacking in expressive power that even simple programs like FizzBuzz are a pain to write, so I've added some new options to [if] to smooth things out.

First, all the [if.condition] tags now work if supplied with a single variable.  The missing variable is assumed to be zero, if the provided variable is a number; False, if the value is True, blank, if the value is a string, and None otherwise.

Second, some new condition codes have been added:

[if.z] and [if.nz] test whether the value is zero or non-zero.  This is effectively identical to using [if.eq] and [if.ne] with a single numeric variable, but may be clearer to the user.

[if.odd] and [if.even] test whether the value is odd or even.  If the variable is not numeric, the result is undefined.

[if.all] tests whether both the variables are true (non zero / non-empty) - effectively an and.
[if.any] tests whether either or both of the variables is true - an or.
[if.one] tests if one and only one of the variables is true - a xor.
[if.none] tests if neither of the variables is true - a nor.

Third, there is now a matching [ifn.condition], which does what you'd expect.

Fourth, and cause for much rejoicing, there is an [else].  Code within [else]....[/else] is evaluated if the last tried conditional block within the current template was not evaluated.  In other words, it works the way you would expect, with one addition: You can have multiple [else] blocks after one [if] block, and all the [else] blocks will be evaluated if the [if] fails.

* The template language without an interesting name.  The Minx API is called Mai (Minx Application Interface); the forthcoming Minx desktop app is called Miko.  I haven't managed come up with a neat and appropriate name for the template language yet.

Posted by: Pixy Misa at 03:06 AM | Comments (6) | Add Comment | Trackbacks (Suck)
Post contains 305 words, total size 3 kb.

1 Checking again.  If this works, it will appear first...

Posted by: Pixy Misa at Tuesday, April 03 2007 02:45 PM (PiXy!)

2 Yep.  But hey, daylight saving is over for me!

Uh, watev.

Posted by: Pixy Misa at Tuesday, April 03 2007 02:46 PM (PiXy!)

3 Hmm.  Just checking something.

Posted by: Pixy Misa at Wednesday, April 04 2007 01:28 AM (PiXy!)

4 Darn.

Posted by: Pixy Misa at Wednesday, April 04 2007 01:28 AM (PiXy!)

5 You could always call it "Mune"... -j

Posted by: J Greely at Thursday, April 05 2007 01:17 AM (2XtN5)

6 Well, I could...

I was actually hope for something with the letters M, T and L in it, but that doesn't seem to work so well, so I'll probably settle for something that just starts with M.

And Mune is as good as anything else. wink

Posted by: Pixy Misa at Thursday, April 05 2007 01:50 AM (PiXy!)

Hide Comments | Add Comment

Comments are disabled. Post is locked.
40kb generated in CPU 0.1038, elapsed 6.8602 seconds.
56 queries taking 6.8397 seconds, 194 records returned.
Powered by Minx 1.1.6c-pink.