0
votes

I have created separate file for each function in IntelliJ Scala using Play framework. How do I call each of functions?

@services = { html code of service.scala.html  }
@navigation ={ html code of navigation.scala.html } 

I have contact.scala and many more functions like this.

My application.controller

object Application extends Controller {
  def index = Action {
    Ok(views.html.index())
  }
  def navigation = Action {
    Ok(views.html.navigation())
  }
  def services = Action {
    Ok(views.html.services())
  }
}

My routes

GET        /                    controllers.Application.index
GET        /navigation          controllers.Application.naigation
GET        /services            controllers.Application.services  

I even have a index.scala.html and main.scala.html. Now how do I call this all in one page?

2

2 Answers

1
votes

You can include a defined template in any other view. For example if you have services.scala.html in your views directory you insert it by putting a following line in any view:

@views.html.services()

Notice that you don't have to define a route or an action mapping in order to include it in a view.

0
votes

Yes, create a template that include all other html contents like,

@(..)(navigation: Html)(services: Html) {
.
.
<html>
  <body>
   @navigation // bring in your individual html contents here or where ever you want.
   @services
   .
   .
  </body>
</html>
}