xdev
xdev

Reputation: 699

play framework chain multiple scala functions

I am writing my first application in Java. In one of my views, I have a couple of helper functions:

@**********************************
* Helper generating table columns *
***********************************@
@tableColumn(content:String) = {
<td>
     @content
</td>
}

and

@**********************************
* Helper to convert boolean to string *
***********************************@
@convertBooleanToString(flag:Boolean) {
    if (flag) {
        "Yes"
    } else {
        "No"
    }
}

I am trying to use these 2 functions as below but getting compiler error.

<tr>
<td>Completed</td>

@for(item <- items) {
@tableColumn(convertBooleanToString(item.isComplete))
}
</tr>

the error that i get is as below:

illegal start of simple expression

Can you please help?

Upvotes: 1

Views: 113

Answers (1)

Schleichardt
Schleichardt

Reputation: 7542

While reproducing I don't get your error message. Please give more code.

But for now you can try:

@**********************************
* Helper generating table columns *
***********************************@
@tableColumn(content:String) = {
<td>
     @content
</td>
}

@**********************************
* Helper to convert boolean to string *
***********************************@
@convertBooleanToString(flag:Boolean) = @{if (flag) "Yes" else "No"}


<tr>
<td>Completed</td>

@for(item <- items) {
@tableColumn(convertBooleanToString(item.isComplete))
}
</tr>

Upvotes: 1

Related Questions