On Friday, 10. January 2003 12:36, Kjetil Kjernsmo wrote:

> > Another idea that strikes me, wouldn't it be handy instead to have a
> > generic taglib that serves the same purpose? Not just
> > AxKit::XSP::Auth has true/false tags. Didn't think further about that
> > yet, but what do you think?
>
> Absolutely! :-) It occured to me that many if not most of the situations
> where you have
> <xsp:logic>if (<ns:something blah blah>) { ... } </xsp:logic>
> where <ns:something> is returning boolean, could be replaced more
> elegantly with such a construct.
>
> So, absolutely, I think this would be a really good idea.

The problem is, what syntax would one use. If we use something XSLT'ish, the 
result would probably look like
<cond:if><cond:expr><ns:something-boolean/></cond:expr><cond:action><p>true</p></cond:action></cond:if>
which is longer but not really prettier than
<xsp:logic>if (<ns:something-boolean/>) {<p>true</p>}</xsp:logic>

now, with some evil intentions it might (should) be possible to do this:
<cond:if tag="ns:something-boolean"><p>true</p></cond:if>

(where we could also supply other attribs, like expr="$foo == 1" or 
param="some_query_param", so it would serve multiple purposes)

Only I'm still not entirely happy, especially regarding the auth taglib:
<xsp:logic>if (<auth:get-single-access type="user"/> eq 'guest') {<p>sorry, 
only for registered users</p>}</xsp:logic>

I don't yet see an elegant solution for this... and then there is the "else".

In the end, for those who like having no perl code at all in their XSP, I 
suggest this one:

<cond:if>
  <cond:expr><ns:tag/></cond:expr>
  <cond:true><p>yeah!</p></cond:true>
  <cond:false><p>oh no!</p></cond:false>
</cond:if>

salted with alternatives for:

  <cond:when value="42"><p>hey, not just true but the answer!</p></cond:when>
  <cond:otherwise><p>too bad nothing matches my expectations</p></cond:when>

so we get the XSP equivalent of <xsl:choose>. As with most taglibs, collapsing 
subelements into parent attributes would be possible as well:
<cond:if expr="$foo == 42">...</cond:if>

But really... would people use that?

-- 
CU
  Joerg

PGP Public Key at http://ich.bin.kein.hoschi.de/~trouble/public_key.asc
PGP Key fingerprint = D34F 57C4 99D8 8F16 E16E  7779 CDDC 41A4 4C48 6F94


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to