Evaluating a variable that contains a method
Hello all, Here's the situation, and I believe it could work - I just need to find the proper syntax. I have a variable that will contain the name of a DTML method; let's call the variable myVariable. Now, through some code logic, I set the variable to equal the name of a DTML method; which we'll call methodA. In that method, I only have some text. So: myVariable = methodA methodA --> (contains the text) --> This is some generic text for this particular method .... Now, here's the situation. I want to display this variable, which should call the method, which should render the text inside. Currently, I'm doing this: <dtml-var name="myVariable"> but I've also tried <dtml-var expr="myVariable"> This will return the name of the method (methodA), but not render what's INSIDE methodA. Does anyone have an idea on how to do that? Thanks in advance, Tommy
I should explain how I got methodA. Basically I concatentated two strings to form 'methodA'. Here's the code: <dtml-let var1="'method'" var2="'A'" myVariable="var1 + var2"> <dtml-var expr="myVariable"> </dtml-let> When run, this returns the string 'methodA', and NOT the text within the method 'methodA'. I believe this clearly defines the question I previously posted. Thanks in advance, Tommy
<dtml-var "_.getitem(myVariable)"> ----- Original Message ----- From: "Tommy Johnson" <tommy@7x.com> To: "Zope List" <zope@zope.org> Sent: Wednesday, June 27, 2001 1:11 AM Subject: [Zope] Evaluating a variable that contains a method
Hello all,
Here's the situation, and I believe it could work - I just need to find the proper syntax.
I have a variable that will contain the name of a DTML method; let's call the variable myVariable. Now, through some code logic, I set the variable to equal the name of a DTML method; which we'll call methodA. In that method, I only have some text. So:
myVariable = methodA methodA --> (contains the text) --> This is some generic text for this particular method ....
Now, here's the situation. I want to display this variable, which should call the method, which should render the text inside. Currently, I'm doing this:
<dtml-var name="myVariable"> but I've also tried <dtml-var expr="myVariable">
This will return the name of the method (methodA), but not render what's INSIDE methodA. Does anyone have an idea on how to do that?
Thanks in advance, Tommy
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Actually, try <dtml-var "_.getitem(myVariable,1)"> It's the 1 that renders it. ----- Original Message ----- From: "Phil Harris" <phil.harris@zope.co.uk> To: "Tommy Johnson" <tommy@7x.com>; "Zope List" <zope@zope.org> Sent: Wednesday, June 27, 2001 1:29 AM Subject: Re: [Zope] Evaluating a variable that contains a method
<dtml-var "_.getitem(myVariable)"> ----- Original Message ----- From: "Tommy Johnson" <tommy@7x.com> To: "Zope List" <zope@zope.org> Sent: Wednesday, June 27, 2001 1:11 AM Subject: [Zope] Evaluating a variable that contains a method
Hello all,
Here's the situation, and I believe it could work - I just need to find the proper syntax.
I have a variable that will contain the name of a DTML method; let's call the variable myVariable. Now, through some code logic, I set the variable to equal the name of a DTML method; which we'll call methodA. In that method, I only have some text. So:
myVariable = methodA methodA --> (contains the text) --> This is some generic text for this particular method ....
Now, here's the situation. I want to display this variable, which should call the method, which should render the text inside. Currently, I'm doing this:
<dtml-var name="myVariable"> but I've also tried <dtml-var expr="myVariable">
This will return the name of the method (methodA), but not render what's INSIDE methodA. Does anyone have an idea on how to do that?
Thanks in advance, Tommy
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Actually, try
<dtml-var "_.getitem(myVariable,1)">
It's the 1 that renders it.
Thank you. I should also mention that I found anothere syntax to do it also. It is slightly different than the underscore syntax I'm used to trying. <dtml-var expr="_[myVariable]"> instead of what I also tried, which was <dtml-var expr="_['myVariable']"> The previous one works, where as the latter one just prints out 'methodA'. Thanks again, Tommy
participants (2)
-
Phil Harris -
Tommy Johnson