Search code examples
scalatemplatesplayframeworkplayframework-2.2

I use the playframework2, in view template, how to use another template which I defined by myself?


I use the playframework2, in view template, how to use another template which I defined by myself?

my firstpage template is:

<!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>

the second page in views fold named slideframework.scala.html and content:

@(message: String)

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

my routes file is:

# 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)

The error is:

[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

I do not know why my slideframework do not find?


Solution

  • just use:

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

    It's NOT about routes