Hey, even though I should know better, I keep messing around with new tags. Doing this I seem to have stumbled upon some interesting ones.
First I noticed the tcl
tag seems to have a bug. it looks for something like:
<tcl>= some code here </tcl>
or content that begins with '=' and then just removes all the spaces and joins them. The above code would result in
somecodehere
being displayed on the page.Otherwise the
tcl
tag runs the code but doesn't print anything on the page. I simplifed the tag code to just run the code and not look for the '=', and I renamed the tag <!>, since nothing prints, dumb but short.
I created a new tag that probably does what the broken tcl
tag is supposed to do: execute and return. I named this tag <=>.
One thing you can't do in the templating system with ease is to get an array element whose name comes from a multiple element of the form @multi.element@. With the tcl
or =
tag, you can do:
<tcl>set a b(@c.d@)</tcl>
<=>set a b(@c.d@)</=>
However, it seems messy to rely on the return value of the set command to print what you want, so here is an alternative tag:
<@>b(@c.d@)</@> if @c.d@ is e,
returns the value of b(e)
<@>i</@> retuns the value of i
Finally, just in case someone needs to run subst:
<subst>The time is now [ns_time]</subst>
Now here is an interesting feature that I never noticed before. Some users complain that the adp templating system doesn't work like the asp one. It just doesn't allow you to arbitrarily escape into tcl and back into html. Well, it appears that this isn't true when using the OpenACS templating system. Here is a simple example, with a minimum .tcl file, the adp includes:
<!>set i 0</!>
<!>while {@i@ < 5} { </!>
<p>@i@</p>
<!>incr i
}</!>
<p>i is now: '<@>i</@>'
<p><subst>the time is now [ns_time]</subst>
<p>i + 1 = '<=>expr @i@ + 1</=>'.
You can check the results