Templating and Views in Play

Play uses the Twirl templating engine for generating HTML from Scala code.

Basic View

@(message: String)
<html>
  <head><title>Welcome</title></head>
  <body>
    <h1>@message</h1>
  </body>
</html>

Rendering a View

def welcome() = Action {
  Ok(views.html.index("Hello from Twirl!"))
}

Place views in the app/views directory.

← PrevNext →