Using twirl for on-the-fly templates

Hello:

(Mostly a copy of in https://github.com/playframework/twirl/issues/227, from which I was redirected to here)

I would like to be able to render template strings on-the-fly without having to rely on placing static files in the resources/ directory of a project.

val str = """
@(x: Int)
Squaring the integer returns @{x * x}
"""

val template = compiler.compile(str)

template.invoke(42) // => "Squaring the integer returns 1764"

My question is, is this possible using Twirl as is, and if not, what do I need to do to be able to get this functionality?