I am trying to pass javascripts specific to a page as a parameter to the main template. This is what I have tried:
main.scala.html:
@(ti
I struggled with this as well, but this seemed to work for me:
main.scala.html:
@(title: String, moreScripts: Html = Html(""))(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
@moreScripts
</head>
<body>
@content
</body>
</html>
test.scala.html:
@moreScripts = { <script src="routes.Assets.at("javascripts/MyJS.js")"></script>}
@main("Page Title", moreScripts) {
<h1>Some content here</h1>
}
Of course, your Javascript file should be located at app/assets/javascripts
as either a standard Javascript or Coffeescript file
This has been discussed on the mailing list. Hope that helps.
@main{ <script src="javascripts/test/test.js" type="text/javascript"></script> } {
<h1>Test</h1>
}