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

Howard M. Lewis Ship closed TAP5-114.
-------------------------------------

    Resolution: Won't Fix

Seems like a good idea, but there's no need to confuse the If component for 
this specific purpose ... create a new component instead.

> improve if component to support block when test is true
> -------------------------------------------------------
>
>                 Key: TAP5-114
>                 URL: https://issues.apache.org/jira/browse/TAP5-114
>             Project: Tapestry 5
>          Issue Type: Improvement
>    Affects Versions: 5.0.15
>            Reporter: Davor Hrg
>            Priority: Minor
>
> This addition can make if component more versatile:
> I came up with this while trying to make the template code more readable.
> The first version was some ifs and loops which I decided to break up into 
> blocks,
> so that logic inside the loop is more readable.
> so one snippet stuck to me as it can be done better...
> the first version was:
> <t:if test="currentContainer"><t:delegate to="containerEditor"/></t:if>
> <t:unless test="currentContainer"><t:delegate 
> to="block:containerDisplay"/></t:unless>
> version 2.
> <t:if test="currentContainer" else="block:containerDisplay"><t:delegate 
> to="containerEditor"/></t:if>
> this is scrambled and akward so I've made a copy of if component and got this:
> <t:if test="currentContainer" render="containerEditor" 
> else="block:containerDisplay"/>
> with "render" block parameter the if component in this case becomes simpler 
> to read
> and can also act as conditional delegate when "else" block parameter is 
> ommited:
> <t:if test="currentContainer" render="containerEditor" 
> else="block:containerDisplay"/>
> this also simply doable by pushing more logic to java code:
> <t:delegate to="containerRender"/>
> public Object getContainerRender(){
>     if(isCurrentContainer){
>         return _containerEditor;
>     }else{
>         return _resources.getBlock("containerDisplay");
>     }
> }

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

Reply via email to