Is it a way to render a pure html file with play framework version 2? I don't want to put it in public/ folder because later on there will be some dynamic information added to it.
Here is my solution:
in routes: I do some configurations as following.
GET /hello.html controllers.Assets.at(path="/public/html", file="hello.html")
GET /public/javascripts/jquery-1.9.0.min.js controllers.Assets.at(path="/public/javascripts", file="jquery-1.9.0.min.js")
GET /public/stylesheets/bootstrap.css controllers.Assets.at(path="/public/stylesheets", file="bootstrap.css")
and then the file structure is as below:
public->HTML->hello.html
public->javascripts->jquery-1.9.0.min.js
public->stylesheets->bootstrap.css
for hello.html , here is its content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel='stylesheet' type='text/css' href='/public/stylesheets/bootstrap.css'>
</head>
<body>
<script src="/public/javascripts/jquery-1.9.0.min.js" type="text/javascript"></script>
</body>
</html>
After these three steps, you can use outside HTML directly. No need to follow Play template to do front-end development work. So now, Play only is responsible for back-end. Front-end developer only needs to operate this public file to do development.
Of course, put your whole static html ie. in index.scala.html
and use simplest possible way:
public static Result index(){
return ok(index.render());
}
That are the basics, you should go trough Play's documentation and samples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With