Reputation: 639
If I pass a boolean value to the view, for example "checked", how to show the different html elements according to the checked value(that is , true or false) ?
#{if ${checked}}
<p>aaa</p>
#{/if}
#{else}
<p>bbb</p>
#{/else}
I try the above code but failed...
Upvotes: 1
Views: 543
Reputation: 5288
In addition to @aaberg response with an inline if :
<input type="checkbox" ${checked ? 'checked="checked"' : ''} />
<span>The previous checkbox is ${checked ? "checked" : "not checked"} !</span>
Upvotes: 3
Reputation: 2273
#{if checked}
<p>aaa</p>
#{/if}
#{else}
<p>bbb</p>
#{/else}
The ${} syntax, is only for printing values into your template. Inside the #{if } tag, playframework expects groovy syntax.
Also, check out the documentation for the #{if} tag.
Upvotes: 4