It's built into the language (in an extendable way). Just

val obj = Obj("replacement")
s"xx ${obj.str} xx"

You can have any Scala expression inside ${...}.

See (or just search for "Scala string interpolation") for more.


Try to create your class like this:

    case class Obj(@BeanProperty str: String)

Here is the scala doc:

Also you can take a look at the project Scalasti which is a interface for StringTemplate:

Related Query

More Query from same tag