1

When I insert arbitrary expressions inside xml literals it seems that result of .toString() is inserted

object Foo {
  override def toString: String = "foo"
}
println(<div>{Foo}</div>) // prints "<div>foo</div>"

Can I customize that process in a way other than overriding toString? Add method toXml or something? Note, I'd like to avoid explicit <div>{Foo.toXml}</div>.

Yaroslav
  • 4,543
  • 5
  • 26
  • 36
  • 2
    There doesn't seem to be a way without explicitly calling the conversion, see http://stackoverflow.com/questions/29052619/scala-implicitly-render-objects-into-complex-xml. – devkat Oct 04 '16 at 10:48

0 Answers0