Reputation: 281
I have the following model:
case class CarBinding(ownerId: Var[String], specs: Var[Option[Specs]])
Specs
is a trait and has the following concrete types:
trait Specs {
def name: String
}
case class SportsCarSpecs(name: String, details: Details) extends Specs
In my Scala.js app, I now want to create a table and list all the entries:
@dom
def buildTable(): Binding[BindingSeq[Node]] = {
val data = Vars.empty[CarBinding]
/* Initial population. */
// Some code...
<br/>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th class="col-md-1">
<small>Owner ID</small>
</th>
<th class="col-md-1">
<small>Specs</small>
</th>
</tr>
</thead>
<tbody>
{for (entry <- data) yield {
<tr>
<td>
<small>
{entry.ownerId.bind}
</small>
</td>
<td>
<small>
{entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
case _ => -
}}
</small>
</td>
</tr>
}}
</tbody>
</table>
</div>
}
However, I get the following error:
';' expected but $XMLSTART$< found.
[error] case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
What am I doing wrong?
Upvotes: 0
Views: 140
Reputation: 170899
This:
entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => {name} <span>{details.ps}</span>
case _ => -
}
isn't a valid expression, so you can't interpolate it in the XML literal. If you had complete XML expressions in both branches, it should work. So the easiest fix I can see is to pull <small>
inside:
<td>
{entry.specs.bind match {
case Some(SportsCarSpecs(name, details)) => <small>{name} <span>{details.ps}</span></small>
case _ => <small>-</small>
}}
</td>
Upvotes: 3