If-then-else in tags or any best practice?

In the default radius tags, is there a way to replicate if-then-else
flow?

Something like:
<r:if_content part=“testy”>
x
<r:else/>
y
</r:if_content>

or

<r:choose>
<r:when part=“testy”>
x
</r:when>
<r:otherwise>
y
</r:otherwise>
</r:choose>

Or, is the idea to use an "r:unless_" with an r:if_ tag:

<r:unless_content part="specs">
 <li class="X">x</li>
</r:unless_content>
<r:if_content part="specs">
 <li class="Y">y</li>
</r:if_content>

-Todd

Right now, the last way you mentioned is the only way I know of.
However,
if you have some better tag designs (with patch preferably), they would
be
welcomed!

Sean

Thanks Sean. I really hope the tone of my original email was not
negative or
condescending. The unless/if works for me, just wondering if there was
a
better way to do it.

The day I’m able to confidently submit a patch will be a good day. I
need to
learn much more Ruby.

Quoting Sean C. [email protected]:

Not at all. Neither did I mean mine to be confrontational. Just trying
to
encourage participation!

Sean

Todd McGrath wrote:

In the default radius tags, is there a way to replicate if-then-else flow?

Something like:
<r:if_content part=“testy”>
x
<r:else/>
y
</r:if_content>

It would be hard to get Radius to parse this.

<r:choose>
<r:when part=“testy”>
x
</r:when>
<r:otherwise>
y
</r:otherwise>
</r:choose>

That’s an interesting idea. Though perhaps it should work more like
Ruby:

<r:case>
<r:when part=“foo”>
x
</r:when>
<r:when part=“bar”>
y
</r:when>
<r:else>
z
</r:else>
</r:case>

The difficulty is that Radius doesn’t provide a way to make true
conditional statements. That’s one of the nice aspects of it being a
tagging library (it isolates you from the conditionals and forces you to
put advanced logic in custom tags).

I suppose the when tag could just have a number of attributes that would
allow you to make predefined comparisons:

url=“…”
url_starts_with=“…”
url_ends_with=“…”
has_part=“…”

But that seems rather convoluted.

Perhaps the case tag could specify an object (doing some sort of
variable expansion) and the when tag could do comparisons:

<r:case object=“${page.title}”>
<r:when equals=“foo”>
x
</r:when>
<r:when ends_with=“bar”>
y
</r:when>
<r:else>
z
</r:else>
</r:case>

But again, it all seems convoluted.


John L.
http://wiseheartdesign.com