Let's say I have the following code:
import scala.xml._
def foo(bar:String) = s"The FOO is $bar"
var xml =
<a type ={foo("attribute")}>
{foo("text node")}
</a>
val txt = "<a>{foo(\"updated\")}</a>"
XML.loadString(txt)
That results in
xml: scala.xml.Elem = <a>{foo("updated")}</a>
What is the canonical way to make it
xml: scala.xml.Elem = <a>The FOO is updated</a>
Is it even possible without reflection?
I guess it's my own fault of trying to make the question as general as possible. The answer I was looking for was some way of updating XML literals from external storage in runtime.
Best way to do that are template engines. There are several options for Scala:
For the purpose of my project I've found Scalate to be the best fit. So, answering my own question, it would look something like this:
with template "test.ssp" being simply: