TML scripting considered harmful
My experience with
Support.Question414 has been enough to face a painful truth: programming in TML is just painful.
Question 414 was supposed to quickly iterate across columns and down rows, and find all cell entries that were not zero.
Simple, right? No, actually I wasted hours on Sunday trying to get the answers I needed and figuring out why it doesn't work. I eventually gave up and wrote it in Perl.
Foswiki has to be able to allow scripting in the text if it is to power mashups etc.
Time to ditch TML for scripting. Control structures are next to impossible to achieve under the macro expansion model.
What other options are there? Javascript? Ruby?
--
MartinCleaver - 09 Feb 2010
PerlPlugin
--
CrawfordCurrie - 09 Feb 2010
PerlPlugin is nice, but without a TOM/DOM, working on tables in the manner that Martin is will always be doomed.
Rather than use the FOREACH in Martin's example, there should be some sort of generic table iterator with the
ContentAccessSyntax to go with it.
--
PaulHarvey - 09 Feb 2010
Compare: Scripting in Confluence:
http://confluence.atlassian.com/display/DISC/Confluence+Reporting+HOWTO+-+5.+Dynamic+Content
{beanshell}
String[] someWords = new String[] {"foo", "bar", "baz"};
for (item : someWords) {
print(item);
}
{beanshell}
And did they need to invent a macro and syntax for each keyword? Nope, they used
http://www.beanshell.org/
--
MartinCleaver - 12 Feb 2010
I'm surprised you picked that as an example to highlight the issue.
FORMATLIST
is no worse and actually has less boilerplate syntax/clutter than this.
And it still doesn't help the root cause of your problem. Or is writing yet-another-table-parser in beanshell a valid solution now?
--
PaulHarvey - 13 Feb 2010