-
Book Overview & Buying
-
Table Of Contents
Mastering play framework for scala
By :
A Twirl template is composed of parameters and content. The following figure shows the components of a login page template called login.scala.html:

The parameters must be declared first since they are used as the parameters of the apply method of the generated template object. For example, for the main.scala.html template, shown in the preceding code, the apply method will be:
def apply/*1.2*/(title: String)(content:play.api.twirl.Html):play.api.templates.HtmlFormat.Appendable = {...}The template content can be HTML as well as Scala code.
For example, let's look at some defaultpages (accessible through the object views.html.defaultpages) bundled along with Play. The default view for this action is not implemented; todo.scala.html has no template parameters and has plain HTML for its content. It is defined as follows:
<!DOCTYPE html>
<html>
<head>
<title>TODO</title>
<link rel="shortcut icon" href="data:image/png;base64...
Change the font size
Change margin width
Change background colour