Reputation: 1190
I would like to do something like that.
Here is the main template :
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/jquery-1.6.4.min.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
And here is another one :
@(user: User)
@main(title = "@user.email - SiteName") {
<b>@user.email (@user.role)</b>
}
The later does not work because it failed with the "@user.email" in the title parameter.
How can I do that ?
PS : I know that I can do this another way (add the "- SiteName" in the main template) but it is just an example to understand how Scala works.
Upvotes: 5
Views: 1693
Reputation: 11274
You have to concatenate the Strings, just as it were normal Scala code (because it is):
@main(title = user.email + " - SiteName") {
<b>@user.email (@user.role)</b>
}
Everything inside @()
is treated as Scala code.
Upvotes: 6