Including multiple blocks from a template to another template

I would like to use the reusable block from the template in my other templates. How can i do this? More specific:

I have a /main.scala.html template containing this tag

@logo_header = {
    <div id="logo-container">
       ...
    </div>
}

a I have another views / errors / notFound.scala.html template where I would like to include the logo_header tag from the main template. I try @ main.logo_header or @ main.logo_header (), but the compilation always says:

The value of logo_header is not a member of the views.html.main object

I looked in the official documentation where they describe, including, but I can’t understand why it doesn’t work.

+5
source share
1 answer

- , . . , , - , . , , .

, :

/_logo_header.scala.html

<div id="logo-container">
   ...
</div>

:

/main.scala.html

<html>
    ...
    _logo_header
    ...
</html>

, , HTML, HTML-.

, , . , Scala, :

/_logo_header.scala.html

@(arg1: String, arg2: String)
<div id="logo-container">
   ...
</div>

/main.scala.html

<html>
    ...
    _logo_header("foo", "bar")
    ...
</html>
+5

All Articles