Question

The documentation has an example of using map

@products.map { p =>
  @display(product = p)
} 

Can I use fold like?

@productOpt.fold(
  <em>-<em>
){ p =>
  @display(product = p)
} 

How should I arrange the code in the template (the above example does not work)?

Était-ce utile?

La solution

You can use fold. I think your problem is the parenthesis. Did you try with curly brackets?

@productOpt.fold{
  <em>-</em>
}{ p =>
  @display(product = p)
} 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top