我在视图模板中使用playframework2,如何使用我自己定义的另一个模板?

时间:2014-04-07 05:16:41

标签: scala templates playframework playframework-2.2

我在视图模板中使用playframework2,如何使用我自己定义的另一个模板?

我的首页模板是:

<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel='shortcut icon' type='image/png' href='@routes.Assets.at("images/favicon.png")'>
<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("bootstrap.min.css"))'>
<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))'></script>
<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("bootstrap.min.js"))'></script>
<style>
body {
    margin-top: 50px;
}
</style>
</head>
<body>
@views.html.slideframework("ssssss")
</body>
</html>

视图中的第二页折叠命名为slideframework.scala.html和content:

@(message: String)

<div class="col-md-9" role="main">
message
</div>

我的路线文件是:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

GET     /                           controllers.Application.index()

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.at(path="/public", file)
GET     /webjars/*file              controllers.WebJarAssets.at(file)

错误是:

[info] Compiling 2 Scala sources to C:\testprojects\hello-play-scala\target\scal
a-2.10\classes...
[error] C:\testprojects\hello-play-scala\app\views\main.scala.html:18: object sl
ideframework is not a member of package views.html
[error]  @views.html.slideframework("ssssss")
[error]              ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 6 s, completed 07/04/2014 3:09:02 PM

我不知道为什么我的幻灯片框架找不到?

1 个答案:

答案 0 :(得分:5)

只需使用:

<body>
    @slideframework("ssssss")
</body>

不是关于路线