You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@clerezza.apache.org by "Tsuyoshi Ito (JIRA)" <ji...@apache.org> on 2010/01/26 17:24:34 UTC

[jira] Resolved: (CLEREZZA-90) ifx method for ssp: a if condition without else

     [ https://issues.apache.org/jira/browse/CLEREZZA-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsuyoshi Ito resolved CLEREZZA-90.
----------------------------------

    Resolution: Fixed
      Assignee: Tsuyoshi Ito

> 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
>            Assignee: 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.