Reputation: 1109
First off, what exactly does $
mean in the Scala Play Template engine?
Second off, I am trying to deal with an type Option in my Scala Play template, and it seems what I am doing should be rather simple. Here is a snippet of code from my template.
@c = { Some(complication) }
<div id="complication">
@Html( (@c.name getOrElse "") ) `
</div>
Where complication is of type Option[T]
. The name
field is of type string.
I've tried extracting it in to a another variable and then referencing the name field from that, but that seems so obtuse, there has to be a better solution it seems.
Upvotes: 1
Views: 323
Reputation: 55569
With $
I think you may be referring to Scala's string interpolation.
Say you have val str: String = "hello"
, then s"$str world"
is equivalent to str + " world"
You don't need the @
symbol inside @Html
.
@Html( (c.name.getOrElse("")))
Upvotes: 2