[Petal] [rfc] if: ... then: ... else: ... modifier

William McKee william at knowmad.com
Thu Sep 11 08:59:49 BST 2003


Hi Steve,

I have no objections but would like to discuss some design ideas to get
input from the list. I can see where there is some benefit to doing an
if..else statement using modifiers if you are working with designers that
use GUI's. The current method of using petal:if statements causes you to
create two separate navbar Search objects to achieve the desired results.

e.g.,
	<a petal:if="search_page" petal:attributes="class nav-selected"
		href="/search.html" class="nav">Search</a>
	<a petal:if="false: search_page" petal:attributes="class nav-unselected"
		href="/search.html" class="nav">Search</a>

BTW, in your example and thus in mine above, did you mean to include
class in the petal:attr as well as a separate attribute? Will Petal
replace the attribute with the dynamic version?

However, the examples you provide are making TAL start to look
complicated. What if you created a modifier that takes three parameters
and returns the value of the 2nd or 3rd parameter based on the trueness
of the 1st? This is kind of like the ?: if form (what's the name of that
function?).

e.g.,
	<a petal:attributes="if: search_page 'nav-selected'
'nav-unselected'">Search</a>

However, this example brings up a problem I had with the date: modifier
where I was trying to pass in a string to be used as the separator.
Jean-Michel claims I should be able to do it, but I did not have any
luck.

I'm out of town for a week so I'll talk to you on my return.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com


More information about the Petal mailing list