incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tsuyoshi Ito (JIRA)" <j...@apache.org>
Subject [jira] Created: (CLEREZZA-90) ifx method for ssp: a if condition without else
Date Tue, 26 Jan 2010 14:16:34 GMT
ifx method for ssp: a if condition without else
-----------------------------------------------

                 Key: CLEREZZA-90
                 URL: https://issues.apache.org/jira/browse/CLEREZZA-90
             Project: Clerezza
          Issue Type: Improvement
            Reporter: Tsuyoshi Ito


In ScalaServerPages when generating xml the if
expression doesn't work as one might expect without else. Namely the
following yields to <a><a/> and not <a><b><b/><a/>

<a>{if(1==1) {<b/>}}</a>

The reason is that if without else returns Unit and thus no value is
available even if the condition is met.

It would be possible to introduces an ifx operator likemethod for which
the following would generate <a><b><b/><a/>:

<a>{ifx(1==1) {<b/>}}</a>

So rather than having to add empty else blocks one could simply use ifx
instead of if.

ifx would be a method defined as :

def ifx(con:  => Boolean)(elem: scala.xml.Elem) :  scala.xml.Elem = {
   if (con) elem else null.asInstanceOf[scala.xml.Elem]
}

contrary to a normal if ifx would require backets, i.e. the following
doesn't compile:

WRONG: <a>{ifx(1==1) <b/>}</a>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message