StringTemplate

Functions for scripting string interpolation.

e.g turn some Context into a string, with use-cases like:

 someJsonDoc = """ { "key" : "{{ record.key.toUpperCase }}", "foo" : "{{ if (record.content.path.to.foo) "x" else "y" }}", "double-host" : "{{ env.HOST * 2 }}"  } """
class Object
trait Matchable
class Any

Type members

Types

type StringExpression[A] = A => String

Value members

Concrete methods

def apply[K : ClassTag, V : ClassTag](expression: String, scriptPrefix: String): () => Message[K, V]

Consider the initial remainingExpressionStr:

Consider the initial remainingExpressionStr:

 "foo {{ x }} bar {{ y * 2 }} bazz"

This should get translated into a function whose body looks like:

val string1 = "foo "
val string2 = { x.toString() }
val string3 = " bar "
val string4 = { (y * 2).toString }
val string5 = " bazz"
string1 + string2 + string3 + string4 + string5
Returns

a mapping of variable names to their RHS codetemplate (constants or functions)

def const[A](value: String): () => A
def newCache[K : ClassTag, V : ClassTag](scriptPrefix: String): Cache[() => Message[K, V]]