Shared Template Library

I am trying to create a view that only stores multiple HTML blocks that can be used by other views. Wanted to know if something like this is possible:

In views.home.common.scala.html:

@component1 = {
  some common html
@component2 = {
  some other stuff


In views.home.sample.scala.html:

import home._



No luck so far and I don't see anything like it in the examples, but the idea is covered in frequently used template cases .


source to share

1 answer

I had the same problem. What I did was define a file for each shared block, and then imported a package containing all of those files.

For example:

In views.common.component1.scala.html:

    Common component 1


In views.common.component2.scala.html:

    Common component 2


In views.main.scala.html:

@(content: Html)

@import common._

<!DOCTYPE html>




All Articles