Luuk D. Jansen
Luuk D. Jansen

Reputation: 4506

Render a boolean as 0 or 1 in Play template

This is a simple question. What is the best way to render a boolean value of an object as '0' or '1' in a template in the Play Framework.

I am creating an XML structure, and the receiving side expect 1 or 0 and not the string 'true' or 'false'.

Upvotes: 0

Views: 286

Answers (2)

Pavel
Pavel

Reputation: 121

Or you can use Java object extensions:

${b.yesno("1", "0")}

Upvotes: 0

Codemwnci
Codemwnci

Reputation: 54914

It is fairly trivial.

${myBoolVal ? 1:0}

Upvotes: 1

Related Questions