[Zope] Evaluating an parameter in a custom tag

Tommy Johnson tommy@7x.com
Fri, 15 Jun 2001 13:54:39 -0800


Hello all,

This really is a quick question, but it does take some explaining, otherwise
the full idea doesn't get across. What I'm trying to accomplish is to have a
custom tag write out an HTML table with 3 columns. Also, it will fill in the
columns with content, which will come from 3 separate DTML Methods. Ok, now
for the meat:

I have a DTML Document from which I call my custom tag. Its syntax is this:
<dtml-customTag attribute1="methodA" attribute2="methodB"
attribute3="methodC">

What this produces is HTML that looks similiar to this:
<table>
  <tr>
    <td>Content from methodA</td>
    <td>Content from methodB</td>
    <td>Content from methodC</td>
  </tr>
</table>

Like I said, the content will be provided through the DTML methods, so one
of those would just contain text (for now) ;>
Something like --> this is methodB:

"Welcome to my site. I hope you enjoy your stay." (without quotes)

The actual code for the custom tag is this:
<dtml-table leftColumn=_['methodA'] middleColumn=_['methodB']
rightColumn=_['methodC']>

This does save correctly, and I tried it with quotes around the passed
values also. That also works.

Now for the problem. I cannot seem to get the tag to evaluate the methods.
What happens is that the attributes take in the literal string
"_['methodA']" and displays that in the HTML table. Like so:

<table>
  <tr>
    <td>_['methodA']</td>
    <td>_['methodB']</td>
    <td>_['methodC']</td>
  </tr>
</table>

So now, here's the question. Is there a way in DTML to tell it to evaluate
_['methodA'] so that when I write:

leftColumn=_['methodA']

it will first see that I want the text within the DTML Method methodA, and
assign that to the attribute leftColumn?


I did something similiar that worked, but it used the <dtml-var> tag. I
wrote this to display an image that I wanted to display 500 pixels wide:

<dtml-var expr="imageName.tag(width=_['methodSize'])">

Within the DTML Method "methodSize", I simply wrote the string (number) 500

So what happened is that the tag evaluated the method, and returned the
string, '500' to make the argument width=500  What I see from this is that
the <dtml-var> tag itself does the evaluation on _['methodSize'], correct?
And if so, then how does it do it?

Sorry for the short novel, and thanks in advance,
Tommy