如何将脚本传递给main.scala.html - 播放! 2 [英] How to pass a script to main.scala.html - Play! 2
本文介绍了如何将脚本传递给main.scala.html - 播放! 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将特定于页面的javascripts作为参数传递给主模板。这就是我的尝试:
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:
@(title: String,moreScripts: Html)(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.7.1.min.js")" type="text/javascript"></script>
@moreScripts
</head>
<body>
@content
</body>
</html>
test.scala.html:
@main("Test",<script src="javascripts/test/test.js" type="text/javascript"></script>) {
<h1>Test</h1>
}
但我得到类型不匹配;发现:scala.xml.Elem必需:play.api.templates.Html
错误。我还尝试在 @ {}
中包装< script>
语句无效。
But I am getting an type mismatch; found : scala.xml.Elem required: play.api.templates.Html
error. I also tried wrapping the <script>
statement in @{}
to no avail.
如何构建< script>
语句,以便将语句识别为HTML?
How do I need to structure the <script>
statement so that it is recognises the statement as HTML?
推荐答案
这已在邮件列表。希望有所帮助。
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>
}
这篇关于如何将脚本传递给main.scala.html - 播放! 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文