Here's a feature I just submitted to the collector. It seems to me that a few tweaks to the dtml-if syntax would be beneficial something like the following would certainly clean up some of the logic I end up writing. <dtml-if X> <a href="a_url"> <dtml-always> link text <dtml-else> (no link currently available) <dtml-then> </a> </dtml-if> What do people think? I've not implemented it but I wouldn't imagine its very hard.
Hi: Could you give an equivalent using the current dtml tags? Thanks, Shalabh ----- Original Message ----- From: Jay, Dylan <djay@lucent.com> To: <zope@zope.org> Sent: Friday, June 23, 2000 12:02 PM Subject: [Zope] (no subject)
Here's a feature I just submitted to the collector.
It seems to me that a few tweaks to the dtml-if syntax would be beneficial
something like the following would certainly clean up some of the logic I end up writing.
<dtml-if X> <a href="a_url"> <dtml-always> link text <dtml-else> (no link currently available) <dtml-then> </a> </dtml-if>
What do people think? I've not implemented it but I wouldn't imagine its very hard.
_______________________________________________ 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 )
On Fri, Jun 23, 2000 at 12:49:16PM +0530, Shalabh Chaturvedi wrote:
Hi:
Could you give an equivalent using the current dtml tags?
From: Jay, Dylan <djay@lucent.com>
<dtml-if X> <a href="a_url"> <dtml-always> link text <dtml-else> (no link currently available) <dtml-then> </a> </dtml-if>
If I understood it correctly: <dtml-if X> <a href="a_url"> </dtml-if> link text <dtml-if X> </a> <dtml-else> (no link currently available) </dtml-if> Or alternatively: <dtml-if X> <a href="a_url">link text</a> <dtml-else> link text (no link currently available) </dtml-if> Or using Jay's proposal: <dtml-if X> <a href="a_url"> <dtml-always> link text </dtml-always> </a> <dtml-else> (no link currently available) </dtml-if> I don't really think this is an improvement. As for <dtml-then>, of course it should be </dtml-else> instead. It's hard to see the point here, and there is no point at all if there isn't a dtml-always (except for XML nitpickness); but with dtml-always there _may_ be a point. <dtml-if X> foo <dtml-always>bar</dtml-always> zoo <dtml-else> goo <dtml-always>mar</dtml-always> moo </dtml-else> woo <dtml-always>far</dtml-always> boo </dtml-if> This will render either: when X is true: foo bar zoo mar woo far boo when X is false: bar goo mar moo far So suddenly order starts mattering. It's a rather convoluted way of achieving this results, but there may be situations where this is useful. I don't know. []s, |alo +---- -- Hack and Roll ( http://www.hackandroll.org ) News for, uh, whatever it is that we are. http://zope.gf.com.br/lalo mailto:lalo@hackandroll.org pgp key: http://zope.gf.com.br/lalo/pessoal/pgp Brazil of Darkness (RPG) --- http://zope.gf.com.br/BroDar
+----[ Lalo Martins ]--------------------------------------------- | On Fri, Jun 23, 2000 at 12:49:16PM +0530, Shalabh Chaturvedi wrote: | > Hi: | > | > Could you give an equivalent using the current dtml tags? | | > From: Jay, Dylan <djay@lucent.com> | > | > > <dtml-if X> | > > <a href="a_url"> | > > <dtml-always> | > > link text | > > <dtml-else> | > > (no link currently available) | > > <dtml-then> | > > </a> | > > </dtml-if> | | If I understood it correctly: | | <dtml-if X> | <a href="a_url"> | </dtml-if> | link text | <dtml-if X> | </a> | <dtml-else> | (no link currently available) | </dtml-if> | | | Or alternatively: | | <dtml-if X> | <a href="a_url">link text</a> | <dtml-else> | link text (no link currently available) | </dtml-if> Or sometimes you just need to rethink what "clean" is... and where you want clean, and where you're willing to be a little dirty. <dtml-call "REQUEST.set('link_url','')"> <dtml-call "REQUEST.set('link_end','(no link currently available)')"> <dtml-if X> <dtml-call "REQUEST.set('link_url','<ahref=a_url>')"> <dtml-call "REQUEST.set('link_url','</a>')"> </dtml-if> <dtml-var link_url>link text<dtml-var link_end> I would do it this way, if I could pre-set that text in an earlier <dtml-call> and the programming logic, would mess up my display flow, it works nicely for <dtml-in> where you have a list of URL's, and you can hide the ugliness in another place. <dtml-in 'url-list'> <dtml-call "setLinkText(REQUEST)"> <dtml-var link_url>link text<dtml-var link_end> </dtml-in 'url-list'> -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
+----[ Andrew Kenneth Milton ]--------------------------------------------- | | Or sometimes you just need to rethink what "clean" is... and | where you want clean, and where you're willing to be a little dirty. | | <dtml-call "REQUEST.set('link_url','')"> | <dtml-call "REQUEST.set('link_end','(no link currently available)')"> | | <dtml-if X> | <dtml-call "REQUEST.set('link_url','<ahref=a_url>')"> | <dtml-call "REQUEST.set('link_url','</a>')"> duh link_end | </dtml-if> -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
On Fri, Jun 23, 2000 at 04:32:39PM +1000, Jay, Dylan wrote:
It seems to me that a few tweaks to the dtml-if syntax would be beneficial
something like the following would certainly clean up some of the logic I end up writing.
<dtml-if X> <a href="a_url"> <dtml-always> link text <dtml-else> (no link currently available) <dtml-then> </a> </dtml-if>
<dtml-if X> <a href="a_url"> link text </a> <dtml-else> link text (no link...) </dtml-if> Now what's cleaner and easier to the eyes? Or for the obfuscated DTML context: <dtml-var "['<A HREF=....>',''][not X]"> link text <dtml-var "['</A>','(no link...)'][not X]"> :-) -- "This company has performed an illegal operation and will be shut down. If the problem persists, contact your vendor or appeal to a higher court." - Signal11 on slashdot
participants (5)
-
Andrew Kenneth Milton -
Jay, Dylan -
Lalo Martins -
Marco Mariani -
Shalabh Chaturvedi