在playframework的视图中是/ else语句

时间:2013-01-11 06:24:19

标签: groovy playframework-1.x

我有一个像这样的条件语句的视图

#{list items: allTasks, as: 'task'}
<div class="task grid_12">

    #{list items:allClients, as: 'client' }
        <div class="client grid_1">

            #{list items:allTasksDone, as: 'taskDone'}

                #{if task.name==taskDone.task.name && client.name ==taskDone.client.name}
                    Done
                #{/if}
                #{else}
                    Not yet
                #{/else}
            #{/list}
        </div>
    #{/list}
</div>
#{/list}

但结果是:如果条件为真,则显示“Done Not Yet”,如果条件为false,则显示“尚未”。 结果似乎是双重的 如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

谢谢帕拉科。是的,这是因为循环变量“taskDone”。我已经检查并修改了我的代码,如下所示:

<div class="task grid_24">
<div class="client grid_3">
Task/Client
</div>
#{list items:allClients, as: 'client' }
<div class="client grid_2">
${client.name} </div>
#{/list}
</div>


#{list items: allTasks, as: 'task'}
<div class="task grid_24">
    <div class="client grid_3">
        ${task.name}
    </div>

    #{list items:allClients, as: 'client' }
    %{
        i =0;
        }%
        <div class="client grid_2">
            #{list items:allTasksDone, as: 'taskDone'}

                #{if (taskDone.task == task && taskDone.client == client )}
                %{
                    i++;
                    }%
                #{/if}


            #{/list}
        <div class="taskStatus grid_2">
        #{if i>0}Done#{/if}
            #{else } Not yet#{/else}
        </div>
        </div>

    #{/list}
</div>
#{/list}