Help with simple dtml-if compare
Bug? Or am I missing something. Create a default document called 'index_html', with these contents: <dtml-var standard_html_header> <dtml-if "id == 'index_html'"> index_html == <dtml-var id> <dtml-else> index_html != <dtml-var id> </dtml-if> <dtml-var standard_html_footer> Basically, we're comparing the document id -- "index_html" to the string "index_html". If you run it, the results say: index_html != index_html Why is that?? Any help? Ideas? Thanks PK
In article <392E2296.B2B3AB8F@danet.com>, Patrick J.M. Keane <keane@danet.com> writes
<dtml-if "id == 'index_html'">
<dtml-if "_['id']=='index_html'"> as discussed yesterday in this list! -- Regards, Graham Chiu gchiu<at>compkarori.co.nz http://www.compkarori.co.nz/index.php Powered by Interbase and Zope
On Fri, 26 May 2000, Patrick J.M. Keane wrote:
Bug? Or am I missing something.
most likely you're missing something. (o8
Create a default document called 'index_html', with these contents:
<dtml-var standard_html_header> <dtml-if "id == 'index_html'"> index_html == <dtml-var id> <dtml-else> index_html != <dtml-var id> </dtml-if> <dtml-var standard_html_footer>
Basically, we're comparing the document id -- "index_html" to the string "index_html".
yep.. well... this is quite a common question, all up. It comes from people using shorthand, but not relaising it. sometimes i wonder if this feature should be removed. the line: <dtml-if "id == 'index_html'"> is actually shorthand for: <dtml-if expr="id == 'index_html'" > which means your expression is handled as a python expression, not a DTML one. In which case, you are comparing a function object (id) with a string object ('index_html'). the simple fix is, of course, to 'call' the function.... <dtml-if "id() == 'index_html'"> should do what you're expecting.
Thanks PK
</waffle> -- Have a better one, Curtis. <dtml-var standard_work_disclaimer>
Thanks for the quick fix. I really thought it was time to go to bed. Now that it makes sense, I have to rethink whether I have enough evidence that I'm tired. :-) pk
<snip>
yep.. well... this is quite a common question, all up. It comes from people using shorthand, but not relaising it. sometimes i wonder if this feature should be removed.
the line:
<dtml-if "id == 'index_html'">
is actually shorthand for:
<dtml-if expr="id == 'index_html'" >
which means your expression is handled as a python expression, not a DTML one. In which case, you are comparing a function object (id) with a string object ('index_html').
the simple fix is, of course, to 'call' the function....
<dtml-if "id() == 'index_html'">
should do what you're expecting.
Um, except that id is not always a method ;-(, hence the _['id'] idiom (see discussion earlier this week) Rik
participants (4)
-
Curtis Maloney -
Graham Chiu -
Patrick J.M. Keane -
Rik Hoekstra