Search code examples
playframework-2.5twirl

Valid output types for play twirl template


What are the valid types that can be generated by a Twirl template in play framework? I know that I can generate HTML. I would like to generate an svg. Is that possible?

If I have a file named foo.scala.html, then I do get a generated class. foo.scala.svg does not result in a class.

Are the options documented anywhere?

I am currently using PlayFramework 2.5.2, but upgrading should be possible.


Solution

  • What are the valid types that can be generated by a Twirl template in play framework?

    https://github.com/playframework/twirl#template-files:

    Template files must be named {name}.scala.{ext} where ext can be html, js, xml, or txt.

    I would like to generate an svg. Is that possible?

    Not out of the box. You can implement a custom format yourself though. See https://www.playframework.com/documentation/2.5.x/ScalaCustomTemplateFormat