[Zope] ZPT condition attribute question

Jim Penny jpenny@universal-fasteners.com
Tue, 21 May 2002 10:59:02 -0400


On Tue, May 21, 2002 at 05:04:38AM -0700, Mark A. Lilly wrote:
> hello,
> i have an input tag, and i want to set the value attribute to either a
> defined value or a blank string. my python expression either returns a
> single instance or an empty list.
> 
> right now, i am using two Input tags in tandem. Only one remains after
> rendering b/c one is removed.  my question, is it possible to write this so
> i don't have to have nearly identical Input tags all over my page?
> 
> thanks,
> mark
> 
> 
> <input type="text" name="input_name"
> 	tal:condition="task/task_name | nothing"
> 	tal:attributes="value task/task_name" />
> 
> <input type="text" name="input_name"
> 	tal:condition="not:exists:task/task_name"
> 	tal:attributes="value string:hi" />

The condition seems not to be necessary at all:

<input type="text" name="input_name" 
   tal:attributes="value task/task_name | nothing" />

should work for the first example -- well, I have only tested

<input type="text" name="input_name" value="some_thing"
   tal:attributes="value task/task_name | nothing" />

I think the second can be expressed as (not tested):

<input type="text" name="input_name" value="hi"
   tal:attributes="value not:exists:task/task_name | default">

Jim Penny

> 
> 
> 
> _______________________________________________
> 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 )
>