Your code has several errors. They just hide each other. :-)
Let's go through them:
@priceTag(amount: Currency) = @{ ... }
The @{ ... }
construct means that everything inside the curly brackets is a block of Scala code. This doesn't rause an error, because your block,
<div class='priceTag {if(amount.toDouble == 0.0d) "FREE"}'>
{if(amount.toDouble > 0.0d) {amount.format("¤#")} else {"FREE"}}
</div>
is actually valid Scala code (because of Scala's XML literals). It's just that Scala recognizes priceTag {if(amount.toDouble == 0.0d) "FREE"}
as the class name of your div
.
What you probably wanted to do is this:
@priceTag(amount: Currency) = {
<div class='priceTag @{if(amount.toDouble == 0.0d) "FREE"}'>
@{if(amount.toDouble > 0.0d) amount.format("¤#") else "FREE"}
</div>
}
Notice the @
signs before the two if
blocks. I have also removed the curly brackets around amount.format("¤#")
and "FREE"
. You can keep them of course, if you want, but they're not required.