score:-1
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 http://docs.scala-lang.org/overviews/core/string-interpolation.html (or just search for "Scala string interpolation") for more.
score:0
Try to create your class like this:
case class Obj(@BeanProperty str: String)
Here is the scala doc: http://www.scala-lang.org/api/current/#scala.beans.BeanProperty
Also you can take a look at the project Scalasti which is a interface for StringTemplate: http://software.clapper.org/scalasti/
Source: stackoverflow.com
Related Query
- Scala - runtime String template
- Casting String to Long in Scala in template play 2.0 template
- Getting the string representation of a type at runtime in Scala
- Scala string template
- Simple String template replacement in Scala and Clojure
- Parsing scala 3 code from a String into Scala 3 AST at runtime
- Scala runtime string interpolation/formatting
- Play scala template syntax for a string
- Compiling Scala source in a string at runtime
- Spark SQL UDF from a string which represents scala code at runtime
- Converting Scala String to Xml in .xml.scala Template
- Scala Play load partial template by String name
- Idiomatic way to convert an InputStream to a String in Scala
- Remove Characters from the end of a String Scala
- How to insert double quotes into String with interpolation in scala
- What is the idiomatic scala way of finding, if a given string contains a given substring?
- Better String formatting in Scala
- How to check to see if a string is a decimal number in Scala
- Declare variable in a Play2 scala template
- What's the difference between raw string interpolation and triple quotes in scala
- How can I construct and parse a JSON string in Scala / Lift
- Scala - Get last two characters from string
- How to find if a Scala String is parseable as a Double or not?
- String interpolation in Scala 2.10 - How to interpolate a String variable?
- Convert list in Scala to a formatted string
- Is string concatenation in scala as costly as it is in Java?
- Generating a class from string and instantiating it in Scala 2.10
- scala String to scala.xml.Elem
- Scala String vs java.lang.String - type inference
- Hex String to Int,Short and Long in Scala
More Query from same tag
- On Spark-cluster.Is there a parameter that controls the minimum run time of the spark job
- Play-json 2.7.1: java.lang.NoSuchMethodError
- Scala reflection: get all constructor arguments of a specific type
- Scala//Squeryl/Play Retrieve multiple values from the same param
- unit testing the session variables
- Can a function literal use type parameter in Scala?
- Shapeless: batch update using Record
- Can you supply an object to a function later in Scala?
- How to generate an unique ID for an class instance in Scala?
- Mongodb scala driver codec for trait and inherited classes
- subtract two columns with null in spark dataframe
- Apache Thrift server logs
- How to pass an ExecutionContext to spray route or better to avoid ask and use tell
- Scala iterator.count for large lists (>int32 size)
- Does Browsers blocking Java affect Scala code
- Type safe aliases from sealed traits
- Any reason why scala does not explicitly support dependent types?
- Creating an instance of an object using Scala combinator parsing
- Spark Scala : Failed to find data source: kafka
- How to pre-select radiobutton- / checkbox-group in the playframework?
- How to use mocks in Scala to mock a singleton object
- java.time in Scala - Getting UTC offset from Time Zone
- How to extract CN from JKS in Java/Scala?
- Polymer&Play Framework - passing an array to a custom tag with template args
- akka.io dispatcher configuration Exception
- Typeclass defined with TraversableLike not applying to List
- Turning a string into a sealed trait using scala chimney
- Scalatest Scalamock behaves differently with same function declared two ways
- In scala multiple inheritance, how to resolve conflicting methods with same signature but different return type?
- Akka Stream Graphs - How to test PartitionWith from akka.stream.contrib