0

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'.

Luuk D. Jansen
  • 4,402
  • 8
  • 47
  • 90

2 Answers2

1

It is fairly trivial.

${myBoolVal ? 1:0}
Codemwnci
  • 54,176
  • 10
  • 96
  • 129
0

Or you can use Java object extensions:

${b.yesno("1", "0")}
Pavel
  • 121
  • 4